had declared the decimals as doubles

What does that mean? " If you had declared the decimals as doubles your values would have been correct "I declared a const that was a decimal, but it should be a constant. Can anyone point out the simple mistake? ( I learn something every time I post here :-D )


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
#include <iostream>
#include <iomanip>
using namespace std;        
int main()			         
{
	//lZ is twelve and B is eight
	//cont is container, bo is Backorder

int lZhearts, Bhearts, lZcont, Bcont, lZbo, Bbo;

//Constants

const int lZihpc =20; //the 20 twelve inch hearts per container
const int  Bihpc =32; //the 32 twelve inch hearts per container

const int  lZic = 42.50; //for the cost of lZ inch containers 
const int Bic =48.50; //for the cost of B inch containers 

//Crt is Cost Container

cout << "  20 twelve inch hearts per container.\n  32 eight inch hearts per container  "<< endl;

		cout << endl;

	//lZ inch heart user input
	cout << "  Enter the number of 12 inch hearts: "; cout << setw(20);
	cin >> lZhearts;

	//B inch heart user input

	cout << "\n  Enter the number of 8 inch hearts: "; cout << setw(20);
	cin >> Bhearts; 
	cout << endl;

//Format
	//captured output
	cout << "  The number of 12 inch hearts = "<< setw(30) << lZhearts << endl;
	cout << "  The number of 8 inch hearts  =  "<< setw(30) << Bhearts << endl;
	cout << "  The number of full 12 inch containers = " << setw(20)<< lZhearts/lZihpc << endl;

	cout << "  12 inch hearts on backorder =  "<< setw(30) << lZhearts % lZihpc << endl;

	cout << "  The number of full 8 inch containers =  "<< setw(20) << Bhearts / Bihpc << endl;
	 
	cout << "  8 inch hearts on backorder =   "<< setw(30) << Bhearts % Bihpc << endl;

	double lZcrt =  lZhearts/lZihpc;
double Bcrt =  Bhearts / Bihpc *  Bic;

	cout << "  Cost of 12 inch hearts shipped = "<< setw(27) << lZcrt * lZic << endl;
	cout << "  Cost of 8 inch hearts shipped = "<< setw(30) << Bcrt << endl;

	double total = lZcrt + Bcrt;
		cout << endl;
	cout << "  Total cost =  "<< setw(48) << Bcrt << endl;
	
	system("PAUSE");
	
return 0;
}
Last edited on
1
2
const int  lZic = 42.50; //for the cost of lZ inch containers 
const int Bic =48.50; //for the cost of B inch containers  


int = integer
42.50 = double
Thanks. Jaybob
Topic archived. No new replies allowed.