Trouble with C++ Lab problem.. Please check my coding! Error in the output

Assignment details: http://storm.cis.fordham.edu/leeds/cisc1600/lab1.pdf ... I feel like I put some things in "double" that should be in "input" and vise versa... So lost right now :(..

My code:

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 }
                                   
double creates a variable to use.
your input section makes use of variables you created above; see how num of shakesphere is in your int area? int is just integer, a whole number, 1,2,3 etc. Double is a decimal number, 3.1415 for example.

So you did not do anything explicitly wrong in terms of double vs input. The question is, does the program do what it needs to do for your assignment? If not, what is not working?
I don't know why its giving me errors T T ... somethings wrong with the program
somethings wrong

Please read:
http://www.catb.org/esr/faqs/smart-questions.html

Your compiler will certainly tell you what's wrong with your code, and where. The error messages are useful; read them. If you don't know what they mean or how to correct it, at least post them.
Topic archived. No new replies allowed.