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

latihan11

By: a guest on Jun 21st, 2012  |  syntax: C++  |  size: 19.02 KB  |  hits: 12  |  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.     #include <iostream>
  2.     #include <string>
  3.     #include <windows.h>
  4.     using namespace std;
  5.      
  6.      
  7.     int main ()
  8.     {
  9.      
  10.      
  11.      
  12.      
  13.      
  14.     //====================================
  15.      
  16.     string name, discount2, trick;
  17.     string serv1, serv2, serv3;
  18.     string serv1b, serv2b, serv3b;
  19.     char srv1, srv2, srv3;
  20.     char cnfirm, cnfirm2, cnfirm3, cnfirmx;
  21.     int confirmy;
  22.     int mon1=0, mon2=0, mon3=0;
  23.     int times1=0, times2=0, times3=0;
  24.     int total1, total2, total3;
  25.     int totalx, totaly, discount;
  26.     //----admin----------------
  27.     int tpatient=0, tincome=0, tfiling=0, tcleaning=0, txray=0;
  28.      
  29.      
  30.      
  31.     startover:
  32. SetConsoleTextAttribute(
  33.     GetStdHandle( STD_OUTPUT_HANDLE ),
  34.     FOREGROUND_INTENSITY              |
  35.     FOREGROUND_BLUE | FOREGROUND_BLUE );
  36.    
  37.     cout<<"###############################################################################"<<endl;
  38.     cout<<"######                                                 ########################"<<endl;
  39.     cout<<"######         MY DENTAL CLINIC SYSTEM                 ########################"<<endl;
  40.     cout<<"######                                                 ########################"<<endl;
  41.         cout<<"###############################################################################"<<endl<<endl;
  42.      
  43.      
  44.     SetConsoleTextAttribute(
  45.         GetStdHandle( STD_OUTPUT_HANDLE ),
  46.         FOREGROUND_INTENSITY              |
  47.         FOREGROUND_YELLOW | FOREGROUND_YELLOW );
  48.      
  49.      
  50.     cout<<"*******************************************************************************"<<endl<<endl;
  51.      
  52.     cout<<"-----------------------------"<<endl;
  53.     cout<<"|  !  |  Press Enter to start"<<endl;
  54.     cout<<"-----------------------------"<<endl<<endl;
  55.     getline(cin,trick);
  56.     cout<<"Patient name: ";
  57.     getline(cin,name);
  58.      
  59.     cout<<"please chose one service number ony on the menu below"<<endl;
  60.     cout<<"[1] --> Filing (RM 100)"<<endl;
  61.     cout<<"[2] --> Cleaning (RM 75)"<<endl;
  62.     cout<<"[3] --> X-Ray (RM 130)"<<endl<<endl;
  63.      
  64.      
  65.     SetConsoleTextAttribute(
  66.         GetStdHandle( STD_OUTPUT_HANDLE ),
  67.         FOREGROUND_INTENSITY              |
  68.         FOREGROUND_BLUE | FOREGROUND_GREEN );
  69.        
  70.     enterback:
  71.      
  72.     cout<<"So, your number of service: "<<endl;
  73.     //-----------------
  74.     cout<<"-----------------------------------------------------------------"<<endl;
  75.     cout<<"-->--[1] --> Filing (RM 100)"<<endl;
  76.     next00:
  77.     cout<<"     Do you want this service? (Y/N)";
  78.     cin>>srv1;
  79.     if (srv1=='y'||srv1=='Y')
  80.     {
  81.             mon1=100;
  82.     }
  83.     else if (srv1=='n'||srv1=='N')
  84.     {
  85.             times1=0;
  86.             goto next1;
  87.     }
  88.     else
  89.     {
  90.     cout<<"==============================================================="<<endl;
  91.     cout<<"|       |  Error!!                                            |"<<endl;
  92.     cout<<"|   !   |  Sorry, please enter Y and y for yes                |"<<endl;
  93.     cout<<"|       |  and N and n for no.                                |"<<endl;
  94.     cout<<"==============================================================="<<endl;
  95.             goto next00;
  96.     }
  97.     cout<<"     Please enter the number of how many times the service needed :";
  98.     cin>>times1;
  99.     cout<<endl;
  100.     //-----------------
  101.     next1:
  102.     cout<<"-----------------------------------------------------------------"<<endl;
  103.     cout<<"-->--[2] --> Cleaning (RM 75)"<<endl;
  104.     next01:
  105.     cout<<"     Do you want this service? (Y/N)";
  106.     cin>>srv2;
  107.     if (srv2=='y'||srv2=='Y')
  108.     {
  109.             mon2=75;
  110.     }
  111.     else if (srv2=='n'||srv2=='N')
  112.     {
  113.             times2=0;
  114.             goto next2;
  115.     }
  116.     else
  117.     {
  118.     cout<<"==============================================================="<<endl;
  119.     cout<<"|       |  Error!!                                            |"<<endl;
  120.     cout<<"|   !   |  Sorry, please enter Y and y for yes                |"<<endl;
  121.     cout<<"|       |  and N and n for no.                                |"<<endl;
  122.     cout<<"==============================================================="<<endl;
  123.             goto next01;
  124.     }
  125.     cout<<"     Please enter the number of how many times the service needed :";
  126.     cin>>times2;
  127.     cout<<endl;
  128.     //-----------------
  129.     next2:
  130.     cout<<"-----------------------------------------------------------------"<<endl;
  131.     cout<<"-->--[3] --> X-Ray (RM 130)"<<endl;
  132.     next02:
  133.     cout<<"     Do you want this service? (Y/N)";
  134.     cin>>srv3;
  135.     if (srv3=='y'||srv3=='Y')
  136.     {
  137.             mon3=130;
  138.     }
  139.     else if (srv3=='n'||srv3=='N')
  140.     {
  141.             times3=0;
  142.             goto next3;
  143.     }
  144.     else
  145.     {
  146.     cout<<"==============================================================="<<endl;
  147.     cout<<"|       |  Error!!                                            |"<<endl;
  148.     cout<<"|   !   |  Sorry, please enter Y and y for yes                |"<<endl;
  149.     cout<<"|       |  and N and n for no.                                |"<<endl;
  150.     cout<<"==============================================================="<<endl;
  151.             goto next02;
  152.     }
  153.     cout<<"     Please enter the number of how many times the service needed :";
  154.     cin>>times3;
  155.     cout<<endl;
  156.     //-----------------
  157.     next3:
  158.     cout<<endl;
  159.      
  160.     cout<<"================================================================="<<endl;
  161.     cout<<"|         |  OK confirm?                                        |"<<endl;
  162.     cout<<"|   ===   |  [Y] Yes                                            |"<<endl;
  163.     cout<<"|   ===   |  [N] No, I want to repeat the service order again   |"<<endl;
  164.     confirmback:
  165.     cout<<"|         |  Answer (Y/N): ";cin>>cnfirm;
  166.     cout<<"================================================================="<<endl;
  167.     if (cnfirm=='y'||cnfirm=='Y')
  168.     {
  169.             cout<<"OK here we go..."<<endl;
  170.             goto calc;
  171.     }
  172.     else if (cnfirm=='n'||cnfirm=='N')
  173.     {
  174.             cout<<"Alright... ";
  175.             goto enterback;
  176.     }
  177.     else
  178.     {
  179.     cout<<"==============================================================="<<endl;
  180.     cout<<"|       |  Error!!                                            |"<<endl;
  181.     cout<<"|   !   |  Sorry, please enter Y and y for yes                |"<<endl;
  182.     cout<<"|       |  and N and n for no.                                |"<<endl;
  183.     cout<<"==============================================================="<<endl;
  184.             goto confirmback;
  185.     }
  186.      
  187.     //================================================
  188.     calc:
  189.     total1=mon1*times1;
  190.     total2=mon2*times2;
  191.     total3=mon3*times3;
  192.     totalx=total1+total2+total3;
  193.      
  194.     if (totalx>=150)
  195.     {
  196.             discount2="15%";
  197.             discount=totalx*15/100;
  198.     }
  199.     else
  200.     {
  201.             discount2="0%";
  202.             discount=0;
  203.     }
  204.      
  205.     totaly = totalx-discount;
  206.      
  207.     //===  for stats =========
  208.     tpatient=tpatient++;
  209.     tincome=tincome+totaly;
  210.     tfiling=tfiling+times1;
  211.     tcleaning=tcleaning+times2;
  212.     txray=txray+times3;
  213.     //===  for stats =========
  214.      
  215.      
  216.     cout<<endl<<endl;
  217.      
  218.     cout<<"*******************************************************************************"<<endl<<endl;
  219.      
  220.     SetConsoleTextAttribute(
  221.         GetStdHandle( STD_OUTPUT_HANDLE ),
  222.         FOREGROUND_INTENSITY              | // Set Text color
  223.         FOREGROUND_GREEN | FOREGROUND_GREEN );// | // Text color.
  224.         //BACKGROUND_INTENSITY              | // Set Background color
  225.         //BACKGROUND_BLACK | BACKGROUND_BLACK | BACKGROUND_BLACK ); // Bg COLOR.
  226.     cout<<"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"<<endl;
  227.     cout<<"XX                                                                           XX"<<endl;
  228.     cout<<"XX                                                                           XX"<<endl;
  229.     cout<<"XX                                                                           XX"<<endl;
  230.     cout<<"XX                          DENTAL CLINIC SYSTEM                             XX"<<endl;
  231.     cout<<"XX                                                                           XX"<<endl;
  232.     cout<<"XX  WELCOME                                                                  XX"<<endl;
  233.     cout<<"XX  Patient name: "<<name<<"                                                   "<<endl;
  234.     cout<<"XX                                                                           XX"<<endl;
  235.     cout<<"XX  Name of service       -Price (RM)-   -Service taken-   -Total-"<<endl;
  236.     cout<<"XX                                                                           XX"<<endl;
  237.     cout<<"XX  [1] --> Filing          RM 100           "<<times1<<"               "<<total1<<""<<endl;
  238.     cout<<"XX  [2] --> Cleaning        RM 75            "<<times2<<"               "<<total2<<""<<endl;
  239.     cout<<"XX  [3] --> X-Ray           RM 130           "<<times3<<"               "<<total3<<""<<endl;
  240.     cout<<"XX                                                                           XX"<<endl;
  241.     cout<<"XX                                                                           XX"<<endl;
  242.     cout<<"XX                                      price before discount: RM "<<totalx<<endl;
  243.     cout<<"XX                                                   discount: "<<discount2<<endl;
  244.     cout<<"XX                                         Amount of discount: RM "<<discount<<endl;
  245.    
  246.     cout<<"                                                        TOTAL: RM "<<totaly<<endl;
  247.    
  248.     cout<<"XX                                                                           XX"<<endl;
  249.     cout<<"XX                                                                           XX"<<endl;
  250.     cout<<"DENTAL                   thank you and come again!                       DENTAL"<<endl;
  251.     cout<<"DENTAL                                                                   DENTAL"<<endl;
  252.     cout<<"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"<<endl<<endl<<endl;
  253.      
  254.      
  255.     SetConsoleTextAttribute(
  256.         GetStdHandle( STD_OUTPUT_HANDLE ),
  257.         FOREGROUND_INTENSITY              | // Set Text color
  258.         FOREGROUND_BLUE | FOREGROUND_GREEN );// | // Text color.
  259.         //BACKGROUND_INTENSITY              | // Set Background color
  260.         //BACKGROUND_BLACK | BACKGROUND_BLACK | BACKGROUND_BLACK ); // Bg COLOR.
  261.      
  262.      
  263.     cout<<"Do you want to enter new patient's service?"<<endl;
  264.     cout<<"================================================================="<<endl;
  265.     cout<<"|   ####  |  Done!                                              |"<<endl;
  266.     cout<<"|   #  #  |                                                     |"<<endl;
  267.     cout<<"|     #   |  Do you want to enter new patient's service?        |"<<endl;
  268.     cout<<"|     o   |                                                     |"<<endl;
  269.     confirmback2:
  270.     cout<<"|         |  Answer (Y/N): ";cin>>cnfirm2;
  271.     cout<<"================================================================="<<endl;
  272.     if (cnfirm2=='y'||cnfirm2=='Y')
  273.     {
  274.             cout<<"OK here we start again... "<<endl;
  275.             goto startover;
  276.     }
  277.     else if (cnfirm2=='n'||cnfirm2=='N')
  278.     {
  279.     //====start=================
  280.      
  281.      
  282.      
  283.     cout<<"================================================================="<<endl;
  284.     cout<<"|   ####  |  Closing                                            |"<<endl;
  285.     cout<<"|   #  #  |                                                     |"<<endl;
  286.     cout<<"|     #   |  Do you want to make the closing statistics now?    |"<<endl;
  287.     cout<<"|     o   |                                                     |"<<endl;
  288.     confirmback3:
  289.     cout<<"|         |  Answer (Y/N): ";cin>>cnfirm3;
  290.     cout<<"================================================================="<<endl;
  291.     if (cnfirm3=='y'||cnfirm3=='Y')
  292.     {
  293.             cout<<"OK here we go... ";
  294.             goto closing;
  295.     }
  296.     else if (cnfirm3=='n'||cnfirm3=='N')
  297.     {
  298.             cout<<"Alright... ";
  299.             goto endprogram;
  300.     }
  301.     else
  302.     {
  303.     cout<<"==============================================================="<<endl;
  304.     cout<<"|       |  Error!!                                            |"<<endl;
  305.     cout<<"|   !   |  Sorry, please enter Y and y for yes                |"<<endl;
  306.     cout<<"|       |  and N and n for no.                                |"<<endl;
  307.     cout<<"==============================================================="<<endl;
  308.             goto confirmback3;
  309.     }
  310.      
  311.      
  312.     //====end===================
  313.     }
  314.     else
  315.     {
  316.     cout<<"==============================================================="<<endl;
  317.     cout<<"|       |  Error!!                                            |"<<endl;
  318.     cout<<"|   !   |  Sorry, please enter Y and y for yes                |"<<endl;
  319.     cout<<"|       |  and N and n for no.                                |"<<endl;
  320.     cout<<"==============================================================="<<endl;
  321.             goto confirmback2;
  322.     }
  323.      
  324.      
  325.      
  326.     closing:
  327.     cout<<"*******************************************************************************"<<endl<<endl;
  328.      
  329.     SetConsoleTextAttribute(
  330.         GetStdHandle( STD_OUTPUT_HANDLE ),
  331.         FOREGROUND_INTENSITY              | // Set Text color
  332.         FOREGROUND_GREEN | FOREGROUND_GREEN );// | // Text color.
  333.         //BACKGROUND_INTENSITY              | // Set Background color
  334.         //BACKGROUND_BLACK | BACKGROUND_BLACK | BACKGROUND_BLACK ); // Bg COLOR.
  335.     cout<<"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"<<endl;
  336.     cout<<"XX                                                                           XX"<<endl;
  337.     cout<<"XX                                                                           XX"<<endl;
  338.     cout<<"XX                                                                           XX"<<endl;
  339.     cout<<"XX                          DENTAL CLINIC SYSTEM                             XX"<<endl;
  340.     cout<<"XX                                                                           XX"<<endl;
  341.     cout<<"XX  Good day Admin!                                                          XX"<<endl;
  342.     cout<<"XX  Statistics for today:                                                    XX"<<endl;
  343.     cout<<"XX                                                                           XX"<<endl;
  344.     cout<<"XX  Num. of patient                   : "<<tpatient<<endl;
  345.      
  346.     cout<<"XX  Num. of Filing service done       : "<<tfiling<<endl;
  347.     cout<<"XX  Num. of Cleaning service done     : "<<tcleaning<<endl;
  348.     cout<<"XX  Num. of X-Ray service done        : "<<txray<<endl;
  349.     cout<<"XX                                                                           XX"<<endl;
  350.    
  351.     cout<<"XX  Total income for today            : RM"<<tincome<<endl;
  352.    
  353.     cout<<"XX                                                                           XX"<<endl;
  354.     cout<<"XX                                                                           XX"<<endl;
  355.     cout<<"DENTAL                                                                   DENTAL"<<endl;
  356.     cout<<"DENTAL                                                                   DENTAL"<<endl;
  357.     cout<<"HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH"<<endl<<endl<<endl;
  358.      
  359.      
  360.      
  361.     endprogram:
  362.      
  363.     SetConsoleTextAttribute(
  364.         GetStdHandle( STD_OUTPUT_HANDLE ),
  365.         FOREGROUND_INTENSITY              | // Set Text color
  366.         FOREGROUND_BLUE | FOREGROUND_GREEN );// | // Text color.
  367.         //BACKGROUND_INTENSITY              | // Set Background color
  368.         //BACKGROUND_BLACK | BACKGROUND_BLACK | BACKGROUND_BLACK ); // Bg COLOR.
  369.      
  370.      
  371.     cout<<"Do you want to enter new patient's service?"<<endl;
  372.     cout<<"================================================================="<<endl;
  373.     cout<<"|   ####  |  Done!                                              |"<<endl;
  374.     cout<<"|   #  #  |                                                     |"<<endl;
  375.     cout<<"|     #   |  Do you want to exit now?                           |"<<endl;
  376.     cout<<"|     o   |                                                     |"<<endl;
  377.     confirmbackx:
  378.     cout<<"|         |  Answer (Y/N): ";cin>>cnfirmx;
  379.     cout<<"================================================================="<<endl;
  380.     if (cnfirmx=='y'||cnfirmx=='Y')
  381.     {
  382.             goto totalend;
  383.     }
  384.     else if (cnfirmx=='n'||cnfirmx=='N')
  385.     {
  386.     //====start=================
  387.      
  388.      
  389.     cout<<"================================================================="<<endl;
  390.     cout<<"|   ####  |  Before return                                      |"<<endl;
  391.     cout<<"|   #  #  |                                                     |"<<endl;
  392.     cout<<"|     #   |  Do you want to add more new record or start        |"<<endl;
  393.     cout<<"|     o   |  fresh record for this clinic?                      |"<<endl;
  394.     confirmbacky:
  395.     cout<<"|         |  [ 1 ] --> add more new record                      |"<<endl;
  396.     cout<<"|         |  [ 2 ] --> start fresh record                       |"<<endl;
  397.     cout<<"|         |  [ 3 ] --> I change my mind, I want to exit         |"<<endl;
  398.     cout<<"|         |  Answer (1/2/3): ";cin>>confirmy;
  399.     cout<<"================================================================="<<endl;
  400.     if (confirmy==1||confirmy==1)
  401.     {
  402.             cout<<"OK here we go... "<<endl;
  403.             goto startover;
  404.     }
  405.     else if (confirmy==2||confirmy==2)
  406.     {
  407.             cout<<"Alright, please wait... "<<endl;
  408.             Sleep(2000);
  409.             system("cls");
  410.             goto startover;
  411.     }
  412.     else if (confirmy==3||confirmy==3)
  413.     {
  414.             cout<<"OK, ";
  415.             goto totalend;
  416.     }
  417.     else
  418.     {
  419.     cout<<"==============================================================="<<endl;
  420.     cout<<"|       |  Error!!                                            |"<<endl;
  421.     cout<<"|   !   |  Sorry, please enter 1 for yes                      |"<<endl;
  422.     cout<<"|       |  and 2 and for no.                                  |"<<endl;
  423.     cout<<"==============================================================="<<endl;
  424.             goto confirmbacky;
  425.     }
  426.      
  427.      
  428.     //====end===================
  429.     }
  430.     else
  431.     {
  432.     cout<<"==============================================================="<<endl;
  433.     cout<<"|       |  Error!!                                            |"<<endl;
  434.     cout<<"|   !   |  Sorry, please enter Y and y for yes                |"<<endl;
  435.     cout<<"|       |  and N and n for no.                                |"<<endl;
  436.     cout<<"==============================================================="<<endl;
  437.             goto confirmbackx;
  438.     }
  439.      
  440.      
  441.      
  442.      
  443.      
  444.     totalend:
  445.     cout<<"then... ";
  446.      
  447.      
  448.      
  449.      
  450.     system ("pause");
  451.     return 0;
  452.     }