Help with HW Problems!!!

I am currently in a C++ Programming class and It's extremely hard for me.
ok the, question is:

12) Marcy's Department store is having a BoGoHo (Buy One, Get One Half Off) sale. The store manager wants a program that allows the salesclerk to enter the prices of two items. The program should both calculate and display the total amount the customer owes. The half off should always be taken on the item having the lowest price. For example, if the items cost $24.99 and $10, the half-off would be take on the $10 item.

- Create an IPO chart for the problem, and then desk-check the algorithm twice. For the first desk-check, use 24.99 and 10 as the prices.

13) Allenton Water Department wants a program that calculates a customer's monthly water bill. The clerk will enter the current and previous meter readings. The program should calculate and display the number of gallons of water used and the total charge for the water. The charge for the water is $7 per 1000 gallons. However, there is a minimum charge of $16.67.

- Create an IPO chart for the problem, and then desk-check the algorithm twice. For the first desk-check, use 13000 and 16000 as the previous and current meter readings.

IF YOU GUYS COULD HELP ME OUT WITH THESE TWO PROBLEMS I WOULD GREATLY APPRECIATE IT. HW IS DUE TMW MORNING!!!

I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.

You're close on "#13". The pricePerGallon is given for you at .007 ($7/1000 gallons). You don't have to prompt the user for the value and its type should not be a char, but a double, and then set to .007.

Then you just have to subtract meterOne from meterTwo (assuming meterTwo is the current reading). Then use the formula: cost = difference * pricePerGallon. Then check if the cost is less than 16.67, set the cost to 16.67.

You're close on "#13". The pricePerGallon is given for you at .007 ($7/1000 gallons). You don't have to prompt the user for the value and its type should not be a char, but a double, and then set to .007.

Then you just have to subtract meterTwo from meterOne (assuming meterTwo is the current reading). Then use the formula: cost = difference * pricePerGallon. Then check if the cost is less than 16.67, set the cost to 16.67.

could you modify my code with what you're saying to help me understand that better?
and sorry about the code tags

could you modify my code with what you're saying to help me understand that better?
and sorry about the code tags

I won't do your homework for you. Give it a shot using the suggestions and post your attempt if you're unable to do it. Your first step would probably be to read the instructions better. Why would you ask the user for the price per gallon if the value is given to you as part of the problem in the first place?

are the variables correct?
are the input items correct?
am i getting closer?

You're still asking the user for the price per gallon. You already know what it is ($7/1000 gallons) so why are you prompting the user for it?

Also, watch your order of operations here: gallonsUsed = meterTwo - meterOne * pricePerGallon. Multiplication has higher precedence than subtraction so you'll need to use parentheses to force the precedence you want: gallonsUsed = (meterTwo - meterOne) * pricePerGallon. But why are you setting it to that anyway? That's calculating cost, but you're assigning it to a variable called gallonsUsed. You are supposed to print out the gallonsUsed separately, so I'd store that in its own variable and then use it in the cost calculation: gallonsUsed = meterTwo - meterOne; cost = gallonsUsed * pricePerGallon.

Bad idea. That seems to suggest you don't understand logic, which is the building block of alls things in programming. Without it, you will get nowhere.
Write a flow chart or pseudo code to figure out the flow and fix it until it matches the logic or flow you want. An important exercise, and will give you a lot.

Originally Posted by Adak

io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.

Originally Posted by Salem

You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.