# Thread: C programming assignment help

1. ## C programming assignment help

I missed a few days of class and missed a lesson on structures and parameters of functions, i am having difficulties completing and assignment based off of them.

Ive read my textbook aswell as other resources provided to me but cant seem to figure out what to do. any help would be greatly appreciated.

Here is the assignment

The LineItem struct is defined as follows:
struct LineItem;
int fruitType;
double unitPrice;
int quantity
An instance of struct LineItem represents part of an order for fruit. The fruitType field stores a numeric code: 1 for apples, 2 for oranges, 3 for bananas. The unitPrice field stores the cost for one fruit. The quantity field stores the number of fruit being ordered.
Your task is to implement the orderPrice function. It should return the total cost of the LineItem passed as the parameter, which is usually the unit price times the quantity. However, there is a special going on if a customer orders 20 or more bananas, in which case there is a 15% discount, meaning the total cost of the LineItem should be reduced by 15%.

Here is the code already provided to me

Code:
```// Don't change the definition of this data type:
struct LineItem {
int fruitType;
double unitPrice;
int quantity;
};

// Implement this function
double orderPrice(struct LineItem item) {

}```
I can do most of the computation for the actual assignment i just need help implementing the function, or if somebody could explain what the next step i could take would be.

Thanks

2. Well, the order price is the unit price multiplied by the quantity. It's almost as simple as that, except that there's a special case for bananas, so you need to check the fruit type: if it's banana, factor in the discount. When you're done, just return the order price.

3. Originally Posted by laserlight
Well, the order price is the unit price multiplied by the quantity. It's almost as simple as that, except that there's a special case for bananas, so you need to check the fruit type: if it's banana, factor in the discount. When you're done, just return the order price.
I didn't read the entire text so thought you were joking about bananas... I would say that Apples should have an increase of, let's say, 200% (Apple is always expensive!)...

4. Don't know man, I keep seeing people go bananas about apples...