How do I get the names to print then ask me for the amount?

Write a program that will ask the user how many of each type of cookie they want and will then print out an itemized receipt.

Bob’s Buttery Buttons - $5.99 a box
Steve’s Savannah Smiles - $6.99 a box
Josh’s Jelly Drops - $3.99 a box
Larry’s Lemon Rounds - $1.00 a box
Kate’s Caramel Creams - $7.49 a box
Your program should
Ask the user how many boxes of each type of cookie the user wants.
Display an itemized receipt showing how many of each type of cookie were ordered and the costs for each
Display the total of how many boxes the user bought and the total of how much money that costs
Display the amount of tax amount
Display the grand total (total + tax)

Ask for and display how much money was recieved from the buyer
and then caculate and display how much change the user is due.
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
    cout<<"Welcome to the Computer Scouts Cookie Ordering System!"<< endl<<endl;
    cout<<"Please let us know how many boxes of each type of cookie you want:"<<endl<<endl;
    cout<<"ITEMS ORDERED:"<<endl;


    cout<<right<<setw(33)<<"Bob's Buttery Buttons : 5.99 X ";
    int b;
    cin >> b;
    double bobBut=5.99*b;


    cout<<"Steve's Savannsh Smiles : 6.99 X ";
    int s;
    cin >> s;
    double steveSav = 6.99*s;


    cout<<right<<setw(33)<<"Josh's Jelly Drops : 3.99 X ";
    int j;
    cin >> j;
    double joshjell = 3.99*j;


    cout<<right<<setw(33)<<"Larry's Lemon Rounds : 1.00 X ";
    int l;
    cin >> l;
    double larryLem = 1.00*l;


    cout<<right<<setw(33)<<"Kate's Caramel Creams : 7.49 X ";
    int k;
    cin >> k;
    double kateCar = 7.49*k;
    cout<<endl<<endl;



    cout<<right<<setw(25)<<"Bob's Buttery Buttons :"<<b<<" boxes = $"<<bobBut<<endl;
    cout<<"Steve's Savannah Smiles :"<<s<<" boxes = $"<<steveSav<<endl;
    cout<<right<<setw(25)<<"Josh's Jelly Drops :"<<j<<" boxes = $"<<joshjell<<endl;
    cout<<right<<setw(25)<<"Larry's Lemon Rounds :"<<l<<" boxes = $"<<larryLem<<endl;
    cout<<right<<setw(25)<<"Kate's Caramel Creams :"<<k<<" boxes = $"<<kateCar<<endl;



    cout<<"TOTAL: "<<setw(41);
    double totalAmount= bobBut+steveSav+joshjell+larryLem+kateCar;
    cout<<" $"<<totalAmount<<endl;


    cout<<"TAX (9.00%):"<<setw(36);
    double taxAmount = totalAmount*.09;
    double taxTotal = taxAmount+totalAmount;
    cout<<"$"<<taxAmount<<endl;



    cout<<"================================================================="<<endl;
    double grandTotal = taxTotal;
    cout<<"GRAND TOTAL"<<setw(37);
    cout<<"$"<<grandTotal<<endl<<endl;


    double moneyRec;
    cout<<"How much money did you receive: ";
    cin>>moneyRec;

    double changeDue = moneyRec-grandTotal;
    cout<<"The amount of change due is:  "<<setprecision(3)<<changeDue<<endl<<endl;


    int totalBox = b+s+l+k+j;
    int largeBox = totalBox/50;
    int rbox = totalBox%50;


    int numSacks = rbox/5;
    rbox = numSacks%5;

    int numBox = rbox;
    cout<<"This order will come in "<<largeBox<<" large cartons, "<<numSacks<<" sacks, and "<<numBox<<" boxes.";



    return 0;
}
Last edited on
That show function, I think it should return the amount of boxes that user want, that int getL() and its kind I think its useless here you can return the value directly from show function. After the value is return multiply it with its price then store it in some variable, now you can count the total price that user should pay
closed account (48T7M4Gy)
Have you thought about using arrays of struct's or classes to program this?

Item[0].name = "Bob's ...", Item[0].price = 5.99, Item[0]. quantity = 3
etc
Item[4]....

You can then add up Item.price * Item.quantity by looping though each item

etc etc
Topic archived. No new replies allowed.