Don't like ads? PRO users don't see any ads ;-)

Untitled

By: ashum20 on May 5th, 2012  |  syntax: C++  |  size: 6.45 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //Internet Store
  2. //By Alan Shum
  3. #include <iostream.h>
  4. int b;                  //graphics card selection
  5. int c=0;                //graphics card quantity
  6. int d;                  //Processor selection
  7. int e=0;                //Processor quantity
  8. int f;                  //hard drive selection
  9. int g=0;                //hard drive quantity
  10. int h;                  //RAM selection
  11. int i=0;                //RAM quantity
  12. int a;                  //main menu choice
  13. int j;                  //return back to beginning
  14. int yn;                 //checkout: remove things in cart.
  15. char takeout;   //take out an item.
  16. int shipment;   //shipment method
  17. double weight=0; //total weight so far
  18. double money=0; //how much money to be paid before taxes
  19. void selection_made();
  20. void selection_made()
  21. {  
  22.     if (a==1)
  23.     {
  24.                 switch (b)
  25.                 {
  26.                         case 1:
  27.                                 money=money+(109.95*c);
  28.                                 weight=weight+(1.2*c);
  29.                                 break;
  30.                         case 2:
  31.                                 money=money+(548.98*c);
  32.                                 weight=weight+(1.4*c);
  33.                                 break;
  34.                         case 3:
  35.                                 money=money+(149.99*c);
  36.                                 weight=weight+(1.1*c);
  37.                                 break;
  38.                         case 4:
  39.                                 money=money+(999.98*c);
  40.                                 weight=weight+(1.9*c);
  41.                                 break;
  42.                         default:
  43.                                 cout<<"Incorrect answer. Enter 5 to return to main menu.\n";
  44.                                 cin>>b;
  45.                                 break;
  46.                 }  
  47.     }
  48.     if (a==2)
  49.     {
  50.         switch (d)
  51.                 {
  52.                         case 1:
  53.                                 money=money+(229.99*e);
  54.                                 weight=weight+(0.2*e);
  55.                                 break;
  56.                         case 2:
  57.                                 money=money+(989.95*e);
  58.                                 weight=weight+(0.3*e);
  59.                                 break;
  60.                         case 3:
  61.                                 money=money+(294.50*e);
  62.                                 weight=weight+(0.3*e);                                 
  63.                                 break;
  64.                         case 4:
  65.                                 money=money+(1000.99*e);
  66.                                 weight=weight+(0.5*e);
  67.                                 break;
  68.                         default:
  69.                                 cout<<"Incorrect answer. Enter 5 to return to main menu.\n";
  70.                                 cin>>b;
  71.                                 break;
  72.                 }
  73.     }        
  74.     if (a==3)
  75.     {
  76.             switch (f)
  77.                 {
  78.                         case 1:
  79.                                 money=money+(84.95*g);
  80.                                 weight=weight+(2.3*g);
  81.                                 break;
  82.                         case 2:
  83.                                 money=money+(261.99*g);
  84.                                 weight=weight+(2.4*g);
  85.                                 break;
  86.                         case 3:
  87.                                 money=money+(200.99*g);
  88.                                 weight=weight+(1.9*g);
  89.                                 break;
  90.                         case 4:
  91.                                 money=money+(385.97*g);
  92.                                 weight=weight+(1.8*g);
  93.                                 break;
  94.                         default:
  95.                                 cout<<"Incorrect answer. Enter 5 to return to main menu.\n";
  96.                                 cin>>b;
  97.                                 break;
  98.                 }
  99.     }
  100.     if (a==4)
  101.     {
  102.                 switch (h)
  103.                 {
  104.                         case 1:
  105.                                 money=money+(20.99*h);
  106.                                 weight=weight+(0.15*h);
  107.                                 break;
  108.                         case 2:
  109.                                 money=money+(44.95*h);
  110.                                 weight=weight+(0.25*h);
  111.                                 break;
  112.                         case 3:
  113.                                 money=money+(51.99*h);
  114.                                 weight=weight+(0.35*h);
  115.                                 break;
  116.                         default:
  117.                                 cout<<"Incorrect answer. Enter 5 to return to main menu.\n";
  118.                                 cin>>b;
  119.                                 break;
  120.                 }                  
  121.     }          
  122. }
  123. int main()
  124. {
  125.         cout<<"Welcome to the Computer Store!\n";
  126.         cout<<"What would you like to buy?\n";
  127.         do
  128.         {
  129.                 cout<<"Main Menu:\n";
  130.                 cout<<"1 - Graphics Cards\n";
  131.                 cout<<"2 - Processors\n";
  132.                 cout<<"3 - Hard Drives\n";
  133.                 cout<<"4 - RAM\n";
  134.                 cout<<"5 - View Cart\n";
  135.                 cout<<"6 - Exit Store or Checkout\n";
  136.                 cout<<"Current amount owed before taxes: $"<<money<<".\n";
  137.                 cout<<"Current weight: "<<weight<<" lbs.\n";
  138.                 cout<<"Choose a selection.\n";
  139.                 cin>>a;
  140.                 switch (a)
  141.                 {
  142.                 case 1:
  143.                         cout<<"Graphics Cards\n";
  144.                         cout<<"1 - Radeon 7750:............$109.95\n";
  145.                         cout<<"2 - Radeon 7970:............$548.98\n";
  146.                         cout<<"3 - Nvidia Geforce 550:.....$149.99\n";
  147.                         cout<<"4 - Nvidia Geforce 690:.....$999.98\n";
  148.                         cout<<"5 - Return to main menu.\n";
  149.                         cout<<"Which selection do you want?\n";
  150.                         cin>>b;
  151.                         if(b==5)
  152.                         {
  153.                                 j=1;
  154.                                 break;
  155.                         }
  156.                         if((b>5)||(b<1))
  157.                         {
  158.                 cout<<"Incorrect Response. Returning to main menu.\n";
  159.                 j=1;
  160.                 break;
  161.             }
  162.                         cout<<"How many do you want?\n";
  163.                         cin>>c;
  164.                         selection_made();
  165.                         break;                                                                                  //make sure to loop it back later
  166.                 case 2:
  167.                         cout<<"Processors\n";
  168.                         cout<<"1 - AMD Opteron 1385:........$229.99\n";
  169.                         cout<<"2 - AMD Opteron 2435:........$989.95\n";
  170.                         cout<<"3 - Core i7 2600K:...........$294.50\n";
  171.                         cout<<"4 - Core i7 3960X:...........$1000.99\n";
  172.                         cout<<"5 - Return to main menu.\n";
  173.                         cout<<"Which selection do you want?\n";
  174.                         cin>>d;
  175.                         if(d==5)
  176.                         {
  177.                                 j=1;
  178.                                 break;
  179.                         }
  180.                         if((d>5)||(d<1))
  181.                         {
  182.                 cout<<"Incorrect Response. Returning to main menu.\n";
  183.                 j=1;
  184.                 break;
  185.             }
  186.                         cout<<"How many do you want?\n";
  187.                         cin>>e;
  188.                         selection_made();
  189.                         break;                                                                                  //make sure to loop it back later AND ADD WEIGHT!!!!
  190.                 case 3:
  191.                         cout<<"Hard Drives\n";
  192.                         cout<<"1 - Crucial 64 GB SSD:.......$84.95\n";
  193.                         cout<<"2 - Crucial 256 GB SSD:......$261.99\n";
  194.                         cout<<"3 - Western 1 TB HD:.........$200.99\n";
  195.                         cout<<"4 - Western 2 TB HD:.........$385.97\n";
  196.                         cout<<"5 - Return to main menu.\n";
  197.                         cout<<"Which selection do you want?\n";
  198.                         cin>>f;
  199.                         if(f==5)
  200.                         {
  201.                                 j=1;
  202.                                 break;
  203.                         }
  204.                         if((f>5)||(f<1))
  205.                         {
  206.                 cout<<"Incorrect Response. Returning to main menu.\n";
  207.                 j=1;
  208.                 break;
  209.             }
  210.                         cout<<"How many do you want?\n";
  211.                         cin>>g;
  212.                         selection_made();
  213.                         break;                                                                                  //make sure to loop it back later
  214.                 case 4:
  215.                         cout<<"RAM\n";
  216.                         cout<<"1 - Crucial 2 GB RAM:........$20.99\n";
  217.                         cout<<"2 - Crucial 4 GB RAM:........$44.95\n";
  218.                         cout<<"3 - Crucial 8 GB RAM:........$51.99\n";
  219.                         cout<<"4 - Return to main menu.\n";
  220.                         cout<<"Which selection do you want?\n";                
  221.                         cin>>h;
  222.                         if(h==4)
  223.                         {
  224.                                 j=1;
  225.                                 break;
  226.                         }
  227.                         if((h>4)||(h<1))
  228.                         {
  229.                 cout<<"Incorrect Response. Returning to main menu.\n";
  230.                 j=1;
  231.                 break;
  232.             }
  233.                         cout<<"How much RAM do you want?\n";
  234.                         cin>>i;
  235.             selection_made();                                                                          
  236.                         break;                                                                                  //make sure to loop it back later
  237.                 case 5:
  238.                         cout<<"Shopping Cart\n";
  239.                         cout<<"Books:                   Quantity:                       Cost:\n";              
  240.  
  241.                         cout<<"Would you like to remove anything from your cart (y/n)?\n";
  242.                         cin>>yn;
  243.                         cout<<"Which item do you want to take out?\n";
  244.                         cin>>takeout;
  245.                         break;
  246.                 case 6:
  247.                         cout<<"Shipping method\n";
  248.                         cout<<"1 - Carrier Pidgeon:(Takes 10-15 business days. Based on 0.99/lb.\n";
  249.                         cout<<"2 - Truck:(Takes 3-4 business days. Based on 0.5/lb.\n";
  250.                         cout<<"3 - Overnight Air Shipment:(Takes 1 business day. Based on 0.25/lb.\n";
  251.                         cout<<"What kind of shipment method do want?\n";
  252.                         cin>>shipment;
  253.                         break;
  254.                 }
  255.         }
  256.         while (j=1);
  257.         return 0;
  258. }