# Thread: HELP!!! C programming Calculations

1. ## HELP!!! C programming Calculations

Hi Everyone,
I'm doing an assignment for uni which is about a small shopping cart.
1. If the user inputs a weight that is greater than 2500grams, the charge would be \$5.50 + \$0.90 for every 400grams over 2500grams, i am able to do the calculate on an separate source code to see it works, but i am unsure how to include it to the original work that i am working on (if that makes any sense....) I have attached the source code for your reference and guidance!!

Thanking for your help !!!  2. > i am able to do the calculate on an separate source code to see it works,
So why didn't you post this code as well?

> else if(weight >= 25000)
> input1 = 5.50;
You put the code you have here.

Code:
```    weight = setValidWeight();
type = setValidType();
age = setValidAge();
printf("\n\nThe type is %.2f\n",type);
printf("The age is %.2f\n",age);
printf("The Weight is %.2f Grams\n",weight);
calculateCharge ();```
But calculateCharge() calls these functions again, prompting you for the same responses.

Consider say
calculateCharge( weight, type, age ); 3. If you want to integrate the code into one file, make the above file, into a function, and call it from your new program. Make sure your new program has any missing include files that the AssigShell file requires.

EZ way to do it. If you need help with that, you'll need to post BOTH programs, so we can see what needs to be done. 4. Hi,
i just want the setValidWeight(); in one of the IF statement to do this; if the input weight is greater than 2500grams, it should cost it has \$5.50 + \$0.90c for every 400grams over 2500grams
i did an rough testing program of that in another source file; have attached it for your references.... 5. Ugh, your program is so short. Just post the code within [code][/code] bbcode tags instead of attaching a source file. People are less likely to want to wade through a wall of code to help you, and by attaching a source file, you give the impression that you have a wall of code that was too long to post, hence you are less likely to get help. else if(weight >= 25000)
input1 = 5.50;

Becomes
Code:
```    else if(weight >= 25000) {
input1 = 5.50;
}``` 7. you could ??
so u can perform multiple calculations under the IF & ELSE IF statements ??......

Code:
```else if(weight >= 25000) {
input1 = weight - 25000;
input2 = input1 / 400;
input3 = input2 * 0.90;

return input3;
}```
is the code above correct ?? Popular pages Recent additions c program help, c programing, maths, shopping cart 