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
|
# include <iostream> //This is regula input output stream.
# include <iomanip> // I am calling a manipulator in order to control the amount of decimal places I want my answer to have.
# include <string> // For the If statement and the else statement input.
using namespace std;
int main()
{ // I open up my code
double Price_of_item_1 = 12.95,Price_of_item_2 = 24.95,Price_of_item_3 = 6.95,Price_of_item_4 = 14.95,Price_of_item_5 = 3.95;
// Knotest the fact that the variables are not just being initilized but they are being called with onlly one line. By the use of " , " commas.
cout<<"Hello sir, I am here to bring you the check. "<< "\n" "\n"; // Talking to the user about the payment.
cout<< "You are looking at the check and see what it says.....\n \n"; // This is as it is, just you looking at the check.
cout<< " Orcha Restaurant-Bringing you the most delicious gormet Indian food :) \n \n"; // Name of the restaurant.
cout<< "$ "<<Price_of_item_1<< "\n" << "$ "<<Price_of_item_2<< "\n" << "$ "<<Price_of_item_3<< "\n"
<< "$ "<<Price_of_item_4<< "\n"<< "$ "<< Price_of_item_5<< " + "<< endl<< "_________"<< "\n"<< "Subtotal : "<<
Price_of_item_1+Price_of_item_2+Price_of_item_3+Price_of_item_4+Price_of_item_5<<endl;
// All of this was squashed together to preserve space, however simplicity was not considered much.
// Knowtest also that I am putting the $ signs and the "\n" before and after the variable is called into play.
// Also knowtest the line "____________". This is the line that comes before the subtotal.
// ALso knotwest that the summation was not done until the end of the object execution.
// ALso do really pay attention to how every inch of the code is spaced. Especially the physical code.
double total_p = Price_of_item_1+Price_of_item_2+Price_of_item_3+Price_of_item_4+Price_of_item_5;
/* This variable was made in order to make the program simpler, cause I could have just let the program to equal the amount like
total_p is equal or ----total_p == $ 63.35, however programs are about declaring variables so that it knows what you are talking about.*/
cout<<"\n"<< "+ Tax (6% of networth) : "<<fixed<< setprecision(2)<< (total_p*.06)<<endl;
/* Knowtest the use of the "fixed" and "setprecision" manipulators. Also the (2) in the setprecision. That indicates that I want 2 decimal places
after the original decimal point in my final calculation. */
double tax_p = total_p*.06;
/* Last, but not least the last declared vaiable. Knowtest the fact that its a double digit. If it were not double like an int I could not have used
the .06 or 6% in the calculation because otherwise the number .06 would have been truncated into the whole 0. */
cout<<"\n"<< "Your grand total is: ---> "<<tax_p + total_p<<endl;
cout<<"********************************************************\n";
cout<<" How will you choose to pay sir? With debit or cash? \n";
cout<<"*********************************************************\n"<<endl;
cout << "Input your payment of choice------debit or cash-----.\n";
string debit_or_cash;
getline (cin, debit_or_cash, '\n') ;
if ( debit_or_cash == "debit" )
{
cout<< "Sorry bro, we dont even have a debit machine... Ma bad \n \n" ;
}
if ( debit_or_cash == "cash" )
{
cout<< " Oh! well if its cash I'll take that Thank You Very Much.\n ";
}
else
{
cout<< "Sorrry you have input an incorrect answer.\n";
}
system("pause");
} // I close my code and finish.
|