I need assistance with my homework

Hi I've been stuck on this question for hours, I'm not sure how to do it.

1. From main, ask the customer which paint color they wish to purchase and how many full gallons of
paint are needed. Design the program to allow the customer to make additional purchases of either
color of paint.
2. Establish a function to deal with each color of paint (5 functions).
1: The function for the LighBlue paint: determine the cost of the paint based upon $20.90 per
gallon. Return the total cost to main.
2: The function for the Gray paint: determine the cost of the paint based upon $22.50 per
gallon. Return the total cost to main.
3: The function for the Wheat paint: determine the cost of the paint based upon $23.25 per
gallon. Return the total cost to main.
4: The function for the Red paint: determine the cost of the paint based upon $21.95 per
gallon. Return the total cost to main.
5: The function for the Green paint: determine the cost of the paint based upon $19.95 per
gallon. Return the total cost to main.
3. Establish a function to print the store title for billing purposes (Line-1&3 starlines, Line-2 for store
name.)
4. Use cout text alignment (left justified, by using cout.width(40))
5. Establish a function that determines a total bill for the customer. This function will receive the totals
from the five paint functions, will compute the final total cost, and will add HST - 13% to the order.
Return this final total to main. Text alignment (left justified, by using cout.width(40))
6. Clear screen before Print a bill for the customer (so that inputted data should disappeared from the
screen). The bill is to be developed in the following order:
the store name, the total cost of each paint color, the total HST, the total bill with sales tax, and the thank
you message. Text alignment (left justified, by using cout.width(40))
7. Be sure that the money amounts are printed as money amounts and setprecision(2).
What are you confused about? Posting your entire assignment and saying that you are confused doesn't help
What have you tried, what part are you having difficulty with? Post your current code so that we can see what're done so far.
Hello cplusplusstudent2021,

To start with help your-self by mentioning what IDE/compiler you are using. If you know what C++ standard the IDE/compiler is set up to use that helps.

Right now I, along with everyone else, have no idea what you have learned and what you can use. It helps to mention what you can use.

Start with #1 and write a function to display the menu. It is much easier to present a menu with numbered choices. Asking a user to enter "LightBlue" you may get "lightblue" or "Light Blue" or even something that has a misspelled word and you would have to anticipate this and account for every possibility.

I can see the use of a switch unless you have not covered this yet. In that case you would have to use if/else else statements.

When I do a menu function I like to have the function only return a valid choice. Otherwise you stay in the function until you get a valid choice.

Work on the menu function. Compile often and fix any errors. You may not have to run and test the code quite as often, but do test what you have written and/or changed.

When #1 is finished move on to #2.

Andy
Here is a little to start with. Can you build upon this?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Example program
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

void storeName() {
    cout << "***************" << endl;
    cout << "The Paint Store" << endl;
    cout << "***************" << endl << endl;
}

void menu() {
   cout << setw(40);
   cout<< left << "(1) Light Blue :";
   cout << right << "$20.90 per gallon\n";
   cout << setw(40);
   cout<< left << "(2) Gray :";
   cout << right << "$22.50 per gallon\n" << endl;
}

void clear() {
    for(int i = 0; i < 50; i++) {
      cout << endl;
    }
}


int main() {
    
    while(true) {
      int input;
      storeName();
      cout << "Choose a color of paint. Or pick (0) to exit." << endl << endl;
      menu();
      cin >> input;
      if(!cin || input == 0) {break;}
    }
 return 0;
}
Last edited on
Topic archived. No new replies allowed.