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 102 103 104 105 106 107 108 109
|
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
struct Coffee
{
enum name {Columbian = 1, French = 2, Italian = 3, House = 4};
int sugar;
int strength;
int size;
bool cream = false;
};
struct Customer
{
char fname[20];
int orderNum[100];
Coffee pdata;
};
int main()
{
Customer order1;
int x;
int answer;
double names[4]={0, 0.25, 0.25, 0};
double array [5]={1.50, 2.10, 2.50, 3.00, 4.25};
string array1[5] = {"Small (1.50)", "Regular (2.10)", "Medium (2.50)", "Large 3.00", "Extra Large (4.25)"};
double total=0;
cout << "***********************************************\n";
cout << "THIS PROGRAM IS GOING TO TAKE YOUR COFFEE ORDER\n";
cout << "***********************************************\n";
cout << "Would you like a cup of coffee?\n";
cout << "1 - Yes\n";
cout << "2 - No\n";
cout << "3 - Quit\n";
cin >> x;
switch(x)
{
case 1:
{
cout<<"Please enter your first name\n";
cin>>order1.fname;
cout << "Please enter the type of coffee:\n ";
cout << "1. Columbian\n 2. French Roast\n 3. Italian Blend\n 4. House?\n";
cin >> order1.pdata.name;
cout << "Please enter the size of the coffee:\n 0-Small\n 1-Regular\n 2-Medium\n 3-Large\n 4-Extra Large";
cin >> order1.pdata.size;
cout << "Please enter the amount of sugar: 0, 1, 2, 3 or 4?\n";
cin >> order1.pdata.sugar;
cout << "Please enter the strength of the coffee:\n 1-Light\n 2-Medium\n 3-Dark\n";
cin >> order1.pdata.strength;
cout << "Cream? Y or N: ";
cin >> order1.pdata.cream;
cout <<"\n\n\n";
cout << "YOUR ORDER\n";
cout << "----------\n";
cout <<"Order for: "<<order1.fname<<endl;
cout <<"Coffee type: "<<order1.pdata.name<<endl;
cout <<"Coffee size: "<<order1.pdata.size<<endl;
cout <<"Amount of sugar: "<<order1.pdata.sugar<<endl;
cout <<"Strength of Coffee: "<<order1.pdata.strength<<endl;
if(order1.pdata.cream == 1)
{
cout << "Cream: No";
}
if(order1.pdata.cream == 0)
{
cout << "Cream: Yes";
}
total= (array[order1.pdata.size])+total;
cout << "\n\nYour total is "<<total;
ofstream myfile;
myfile.open("CustOrder.dat");
myfile << "Order: \n";
myfile << "Coffee Type: " <<order1.pdata.name <<endl;
myfile << "Size: " << order1.pdata.size <<endl;
myfile << "Sugar: " <<order1.pdata.sugar <<endl;
myfile << "Strength: " <<order1.pdata.strength <<endl;
myfile << "Cream: "<< order1.pdata.cream <<endl;
myfile << "Your total is: " << total <<endl;
break;
}
case 2:
{
cout<< "Would you like to see your order? ";
cin>>answer;
break;
}
case 3:
{
cout<< "Goodbye";
return 0;
}
}
return 0;
}
|