struct in C programming

Completed Posted 5 years ago Paid on delivery
Completed Paid on delivery

/* *******************

File name: trans.h

*******************

An online store sells 10 items and allow users to add items to

their shopping carts then produce an invoice upon completion of

each transaction */

struct StockItem{

int s_id;

char s_desc[100];

float s_price;

} stock_list[10] = {

{111, "50\" LED TV", 1500.00}, {112, "75\" Smart LED TV", 12000.00},

{211, "Home Theater", 250.00}, {221, "3D Sound System", 300.00},

{511, "6\" e-reader", 400.00}, {611, "64GB USB Flash Drive", 50.00},

{612, "128GB USB Flash Drive", 95.00}, {621, "64GB Micro SD Card", 75.00},

{711, "7\" Tablet", 300.00},{611, "10.1\" Tablet", 500.00}

};

/* A transaction item stores the item's id and quantity */

typedef struct Item{

int item_id;

int quantity;

} Item;

/* A transaction consists of the name of the customer, number

of purchased items and array of purchased items */

struct Transaction{

char customer_name[100];

int items_count;

Item* items;

};

/* 1- read_item reads an item information from the keyboard and returns it */

Item read_item();

/* 2- new_trans prepares a transaction structure with a customer name cn

and an empty list of items, the list should big enough to hold (size)

Items, and returns a pointer to the transaction */

struct Transaction* new_trans(char* cn, int size);

/* 3- purchase_item adds the item (it) to the transaction (tr). If (tr)

contains (it) already, just increase the quantity of the corresponding

item, otherwise add (it) as a new item */

void purchase_item(struct Transaction* tr, Item it);

/* 4- remove_item removes the item (it) from the transaction (tr) if it exists.*/

void remove_item(struct Transaction* tr, Item it);

/* 5- calc_total takes a transaction and returns the total amount

that should be paid by the customer for this transaction */

float calc_total(struct Transaction* tr);

/* 6- main function does the following:

- ask the customer to enter his/her name

- ask the customer to enter number of items in his transaction

- creates a new transaction with a suitable size

- reads the items from the keyboard and add them to the transaction

- printf an invoice of the transaction in the form:

Mr./Mrs. <Customer Name>

Total amount: S.R. <Total Amount> */

C Programming C# Programming C++ Programming

Project ID: #16610975

About the project

6 proposals Remote project Active 5 years ago

Awarded to:

thewebscraper

Hi, I can help you with your assignment in struct. I can finish this in a few hours and guaranteed A+ grade.

$30 USD in 0 days
(16 Reviews)
4.5

6 freelancers are bidding on average $28 for this job

mehfuza

Dear Sir, I have read and understood your project requirements and I'm very interested to work on it. I have experience of programming in C. I have done many programs in C and I write well formatted code with comments. More

$20 USD in 1 day
(24 Reviews)
4.5
bogdan84

I have a lot of experience in programming (more than 15 years). This looks to be a very easy task, I can provide a small demo version is you like.

$25 USD in 1 day
(9 Reviews)
3.2