1. 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!!!

2. Pick one and start. What have you tried?

3. I've tried both. I can't quite grasp this whole thing because this is my first actual C++ programming class with not much intro ahead of it.

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
//declare variables
double totalBill = 0.0;
double meterTwo = 0.0;
double gallonsUsed = 0.0;
char pricePerGallon = ' ';
double total = 0.0;

//enter input items
cout << "Meter One: ";
cin >> meterOne;
cout << "Meter Two: ";
cin >> meterTwo;
cout << "Price Per Gallon: ";
cin >> pricePerGallon

thats where i'm at for #13 but its ALL wrong =/

and this is my #12:

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
//declare variables
double firstShoe = 0.0;
double secondShoe = 0.0;
char halfOff = ' ';
double total = 0.0;

//enter input items
cout << "First Shoe: ";
cin >> firstShoe;
cout << "Second Shoe: ";
cin >> secondShoe;
cout << "Half Off (Y or N): ";
cin >> halfOff;

//calculate the total
total = firstShoe + secondShoe / halfOff;
if (toupper(halfOff)=='Y')
total = total +5;

but it's wrong as well...
I really need A LOT of help

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.

6. As for "#12", use this logic:
Code:
```if costOfItemOne is less than costOfItemTwo
costOfItemOne equals costOfItemOne divided by 2
else
costOfItemTwo equals costOfItemTwo divided by 2```

7. Originally Posted by itsme86

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

8. Originally Posted by NikeLover
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?

9. Code:
```#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
//declare variables
double meterOne = 0.0;
double meterTwo = 0.0;
double gallonsUsed = 0.0;
double pricePerGallon = ' ';
double total = 0.0;

//enter input items
cout << "Meter One: ";
cin >> meterOne;
cout << "Meter Two: ";
cin >> meterTwo;
cout << "Price Per Gallon: ";
cin >> pricePerGallon

//calculate the total
;gallonsUsed = meterTwo - meterOne * pricePerGallon;
if (toupper(pricePerGallon)=='N')
total = total +7;

//display total
cout << fixed << setprecision(2);
cout << "Total: \$" << total << endl;

return 0;
}```
are the variables correct?
are the input items correct?
am i getting closer?

10. Did you compile it?
Does it compile OK, or give you error messages?

Did you run it?
What did you type in? Does the answer look correct?

Being able to do these things are all part of the skills required.

11. Originally Posted by NikeLover
Code:
```#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
//declare variables
double meterOne = 0.0;
double meterTwo = 0.0;
double gallonsUsed = 0.0;
double pricePerGallon = ' ';
double total = 0.0;

//enter input items
cout << "Meter One: ";
cin >> meterOne;
cout << "Meter Two: ";
cin >> meterTwo;
cout << "Price Per Gallon: ";
cin >> pricePerGallon

//calculate the total
;gallonsUsed = meterTwo - meterOne * pricePerGallon;
if (toupper(pricePerGallon)=='N')
total = total +7;

//display total
cout << fixed << setprecision(2);
cout << "Total: \$" << total << endl;

return 0;
}```
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.

12. didn't figure it out. just gonna move on.

13. 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.