So I was working on this assignment for class and got this far. The output doesn't match the examples and I have been fiddling with it for hours trying to figure out what is wrong. Any pointers?
So I was working on this assignment for class and got this far. The output doesn't match the examples and I have been fiddling with it for hours trying to figure out what is wrong. Any pointers?
Could you explain what are you trying to achieve?
I dont think my explanation will make sense so I am just going to write down what it says:
Write a program to mimic this process. Ask the user to enter the size (in ounces) of the juice containers you buy, as well as the price of those containers (in dollars). Then prompt the user to enter how many times the roommate took juice. Finally, read the amount the roommate took each time. Every time the total value of the juice equals or exceeds $10, print out “Your roommate owes you $10.00.” After all the numbers are entered, if the roommate owes any money, print out the value owed.
And heres an example:
What is the weight (in oz.) of the original container of OJ?
64
What is the cost of the original container of OJ in dollars?
3.79
How many times did your roommate take your juice?
10
How much juice did your roommate take this time (in oz.)?
30
How much juice did your roommate take this time (in oz.)?
34
How much juice did your roommate take this time (in oz.)?
24
How much juice did your roommate take this time (in oz.)?
40
How much juice did your roommate take this time (in oz.)?
64
Your roommate owes you $10.00.
How much juice did your roommate take this time (in oz.)?
64
How much juice did your roommate take this time (in oz.)?
64
How much juice did your roommate take this time (in oz.)?
18
Your roommate owes you $10.00.
How much juice did your roommate take this time (in oz.)?
20
How much juice did your roommate take this time (in oz.)?
20
Your roommate owes you $2.38.
This is an assignment so I do want to do this on my own just cant see where i went wrong and wanted some tips
It should beCode:if (calculation >= 10){ printf("Your roommate owes you $10.00.\n"); calculation = 0;
calculation = calculation - 10.0;
Also, try naming your variables better.
For example,
amountowed = amountowed + ( ounces * priceperoz );
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.