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
|
1 //Name
2 // Feb 14th. 2018
3 // Code will be used to practice input & output commands, use of variables, and basic arithmetic.
4
5 #include <iostream>
6 using namespace std;
7
8 int main()
9 {
10 // variables
11 string fname;
12 int name_of_cervantes, name_of_homer, name_of_shakespeare, num_of_cervantes, num_of_homer, num_of_shakespeare, tax;
13 double cost_per_cervantes, total_cervantes_cost, cost_per_homer, homer_cost, total_homer_cost, cost_per_shakespeare,total_shakespeare_cost, grand_total, user_pay, user_amoun t, change, total_cost;
14
15 // init
16
17 cost_per_cervantes= 41.25
18 cost_per_homer= 15.85
19 cost_per_shakespeare= 30.50
20
21 // input
22 cout << "Welcome to the Bronx Bookstore ";
23 cout << "Enter your first name : ";
24 cin >> fname;
25 cout << "Enter number of Cervantes books : ";
26 cin >> num_of_cervantes;
27 cout << "Enter number of Homer books : ";
28 cin >> num_of_homer;
29 cout << "Enter number of Shakespeare books : ";
30 cin >> num_of_shakespeare
31 cout << "Total cost of order is : " << endl;
32 cin >> total_cost;
33 cout << "How much money will you pay? : ";
34 cin >> user_pay;
35
36
37 // procesing
38
39 total_cervantes_cost= num_of_cervantes * cost_per_cervantes;
40 total_homer_cost= num_of_homer * cost_per_homer;
41 total_shakespeare_cost= num_of_shakespeare * cost_per_shakespeare;
42 total_cost= total_cervantes_cost + total_homer_cost + total_shakespeare_cost;
43 tax= total_cost * .10;
44 grand_total= total_cost + tax;
45 cout << "Total cost is : " << grand_total << endl;
46 cout << "How much do you want to pay?: ";
47 cin >> user_amount;
48 change= user_amount - grand_total;
49
50 // output
51
52 cout << "-------- "
53 cout << "Customer :" << fname;
54 cout << "-------- " << endl;
55 cout << "Item Number Price " << endl;
56 cout << "Cervantes " << num_of_cervantes << " " <<total_cervantes_cost;
57 cout << "Homer " << num_of_homer << " " <<homer_cost;
58 cout << "Shakespeare " << num_of_shakespeare << " " << total_shakespeare_cost;
59 cout << "-------- " << endl;
60 cout << "Tax " << total_cost * .10;
61 cout << "-------- " << endl;
62 cout << "Total " << total_cost <<endl;
63 cout << "User pay " << user_pay <<endl;
64 cout << "-------- " << endl;
65 cout << "Change " << user_pay - grand_total;
66
67 return 0;
68 }
|