Help please, cant figure out equation.

Can anyone spot what I've messed up in case b, its giving out completely wrong answers for the fondant and butter-cream variables.

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
94
95
96
97
98
99
100
101

#include <iostream>
#include <cctype>
#include <string>
#include <iomanip>
#include <cmath>
//ADD OTHER INCLUDE FILES HERE

using namespace std;

int main()
{
	//VARIABLE DEFINITIONS
	char choice, A, B, C;
	double tax = .0975, price, taxAmount, total, totalSize;
	int spongeCake, quantity, size, buttercream, fondant;

	const int increment = 2;

	
	string line(80, '-');
	
	do
	{		
		cout << "\t\t\tCAKE BOSS\n" << endl;
		cout << "What would you like to do, Buddy?\n" << endl;
				
		cout << "A - SELL A CAKE\n";
		cout << "B - MAKE A CAKE\n";
		cout << "C - END PROGRAM\n";
		cout << "CHOOSE A, B, or C:   " << endl;
		cin >> choice;
		
		choice = toupper(choice);
		
		while (choice != 'C' && choice != 'B' && choice != 'A')
		{
			cout << "Invalid. Please enter A valid selection, either A, B, or C.\n";
			cout << "Press enter to continue and try again.\n";
			cin >> choice;
		}

		switch (choice)
		{
	//SELL A CAKE
			case 'A': 
				choice == A;
				cout << line << endl;
				cout << setw(44) << "SELL CAKE" << endl << endl;
				cout << "How many cakes have you sold?\n" << endl;
				cin >> quantity;
				cout << "What is the price of one cake?\n" << endl;
				cin >> price;
				total = quantity * price;
				taxAmount = total * tax;
				
				cout << setprecision (3) << fixed << endl;
				cout << setw(15) << "TOTAL" << "\t$" << setw(10) << total << endl;
				cout << setw(15) << "TAX AMOUNT" << "\t$" << setw(10) << taxAmount << endl;
				cout << setw(15) << "TAX" << "\t$" << setw(10) << tax << endl;
				break;
	// Make A Cake		
			case 'B':
				choice == B;
				cout << line << endl;
				cout << setw(44) << "MAKE CAKE" << endl << endl;
				cout << "How large is the largest cake in inches?\n";
				cout << "Must be an even number larger than 8:";
				
				cin >> size;
				while ( size % 2 == 0 )
				{
					cout << "Please enter an even number greater than 8: \n";
					cin >> size;
				}
				fondant = (size + 8) * 2;
				buttercream = size / 8;
				
				cout << line << endl;
				cout << setprecision(2) << fixed << endl;
				
				cout << setw (10) << "Size" << setw (10) << "Fondant\t"  <<"Buttercream" << endl << endl;
				
				for (size = 1; size <= 100; size += 2)
				{
					cout <<setw (10) << size <<setw (10) << fondant << setw (10) << buttercream << endl << endl << endl;
				}
				break;
			
			case 'C':
					choice == C;
					break;
					
		default :
			cout << "INVALID INPUT. Please enter A, B, or C." << endl;
		}		
		
	} while (choice != 'C');
	
	return 0;
}
Topic archived. No new replies allowed.