struct in C programming

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

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 */

/* 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> */

Kĩ năng: Lập trình C, Lập trình C#, Lập trình C++

Về Bên Thuê:
( 1 Nhận xét ) Riyadh, Saudi Arabia

ID dự án: #16610975

Được trao cho:

thewebscraper

\$30 USD trong 0 ngày
(12 Đánh Giá)
4.2

8 freelancer đang chào giá trung bình \$28 cho công việc này

\$25 USD trong 1 ngày
(110 Nhận xét)
5.9
\$30 USD trong 2 ngày
(5 Nhận xét)
4.0
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. Thêm

\$20 USD trong 1 ngày
(19 Nhận xét)
4.3
kalyanprakash4

\$25 USD trong 1 ngày
(11 Nhận xét)
3.6
\$40 USD trong 2 ngày
(8 Nhận xét)
3.2
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 trong 1 ngày
(7 Nhận xét)
2.9
\$25 USD trong 1 ngày
(0 Nhận xét)
0.0