In: Computer Science
why do I keep getting errors?
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
const int CHEESE_PIZZA = 11;
const int SPINACH_PIZZA = 13;
const int CHICKEN_PIZZA = 14;
cout << "Assignment 07" << endl;
cout << "Program written by Carol" << endl <<
endl;
cout << " *********** MENU ***********" << endl;
cout << setw(9) << "ITEM" << setw(20) << "PRICE" << endl;
cout << " (1) Cheese Pizza" << setw(8) << "$"
<< CHEESE_PIZZA << endl;
cout << " (2) Spinach Pizza" << setw(7) << "$"
<< SPINACH_PIZZA << endl;
cout << " (3) Chicken Pizza" << setw(7) << "$"
<< CHICKEN_PIZZA << endl;
cout << endl;
cout << "What do you want? ";
int option;
cin >> option;
cout << "How many? ";
int quantity;
cin >> quantity;
int price;
switch (option)
{
case 1:
price = CHEESE_PIZZA;
break;
case 2:
price = SPINACH_PIZZA;
break;
case 3:
price = CHICKEN_PIZZA;
break;
default:
cout << "Please select valid item from menu. ";
break;
return 1;
}
int amount = price * quantity;
cout << "Your Bill: $ " << amount << endl;
cout << endl;
return 0;
Your code had minor fixes. Below is the fixed code..
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
const int CHEESE_PIZZA = 11;
const int SPINACH_PIZZA = 13;
const int CHICKEN_PIZZA = 14;
cout << "Assignment 07" << endl;
cout << "Program written by Carol" << endl <<
endl;
cout << " *********** MENU ***********" << endl;
cout << setw(9) << "ITEM" << setw(20) <<
"PRICE" << endl;
cout << " (1) Cheese Pizza" << setw(8) <<
"$"
<< CHEESE_PIZZA << endl;
cout << " (2) Spinach Pizza" << setw(7) <<
"$"
<< SPINACH_PIZZA << endl;
cout << " (3) Chicken Pizza" << setw(7) <<
"$"
<< CHICKEN_PIZZA << endl;
cout << endl;
cout << "What do you want? ";
int option;
cin >> option;
cout << "How many? ";
int quantity;
cin >> quantity;
int price;
switch (option)
{
case 1:
price = CHEESE_PIZZA;
break;
case 2:
price = SPINACH_PIZZA;
break;
case 3:
price = CHICKEN_PIZZA;
break;
default:
cout << "Please select valid item from menu. ";
break;
return 1;
}
int amount = price * quantity;
cout << "Your Bill: $ " << amount << endl;
cout << endl;
return 0;
}


GOOD LUCK!