Need Help? Contact the Espiya Helpdesk. CLICK HERE


Author Topic: Help about sa Looping  (Read 1628 times)

BebeAdik

  • Active - First Star
  • *
  • Posts: 70
  • Karma 0
  • Once a Adik always an Adik!
Help about sa Looping
« on: September 02, 2013, 10:16:03 pm »
#include <cstdlib>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
      int days, Total;
      char ch;
   
   int room;
      cout<<setw(60)<<"**********Happy Island Resort**********"<<endl;
      cout<<"\t[J] Japan \n";
      cout<<"\t[K] Korea \n";
      cout<<"Where did you stay? "<<endl;
      cin>>ch;
   
   if(ch == 'J' || ch == 'j')
   {
      cout<<"Types of room:"<<endl;
      cout<<"\t[1] Aincrad Room \n";
      cout<<"\t[2] Fairy Tail Room \n";
      cout<<"\t[3] Shiganshina Room \n";
      cout<<"What is the type of room? ";
      cin>>room;
      cout<<"How many days? ";
      cin>>days;
           
      switch(room)
   {
   
   
   case 1:
      {
      
         float SAO[4]={2550.75,3550.75,5000.50, 4500.75};
      int total1;
        cout<<"Service Charge";
          cout<<setw(25)<<"$2550.75"<<endl;
       cout<<"Kimono(Japanese Dress)";
          cout<<setw(17)<<"$3550.75"<<endl;
       cout<<"Futons(5 beds)";
          cout<<setw(25)<<"$5000.50"<<endl;
       cout<<"Electricity Fee";
          cout<<setw(24)<<"$4500.75"<<endl;
       total1=SAO[0]+SAO[1]+SAO[2]+SAO[3];
       cout<<setprecision(10)<<"Total of extra fee is: "<<setw(9)<<"$"<<total1<<endl;
        Total=days*total1;
        cout<<"The total amount is: "<<setw(11)<<"$"<<Total<<endl;
       system ("pause");
       system("cls");
       cout<<"Arigatou gozaimasu! Thank you for choosing Happy Island Resort."<<endl;
       cout<<"We hope you enjoyed your stay and experienced Japan's Culture"<<endl;
    }
       break;
   case 2:
      {
      double Service = 2550.75,Hanbok = 3550.75,Futons = 8000.50, Elec = 4500.75, total2;
         cout<<"Service Charge";
          cout<<setw(25)<<"$2550.75"<<endl;
       cout<<"Kimono(Japanese Dress)";
          cout<<setw(17)<<"$3550.75"<<endl;
       cout<<"Futons(8 beds)";
          cout<<setw(25)<<"$8000.60"<<endl;
       cout<<"Electricity Fee";
          cout<<setw(24)<<"$4500.75"<<endl;
      
       total2=Service+Hanbok+Futons+Elec;
       cout<<"Total of extra fee is: "<<setw(9)<<"$"<<total2<<endl;
      
      Total=days*total2;
      cout<<"The total amount is: "<<setw(11)<<"$"<<Total<<endl;
      system ("pause");
       system("cls");
       cout<<"Arigatou gozaimasu! Thank you for choosing Happy Island Resort."<<endl;
       cout<<"We hope you enjoyed your stay and experienced Japan's Culture"<<endl;
      }
      break;
   case 3:
      {
      
      double Service = 2550.75, Hanbok = 3550.75, Futons = 10250.60, Elec = 7550.75, total3;
      cout<<"Service Charge";
         cout<<setw(25)<<"$2550.75"<<endl;
       cout<<"Kimono(Korean Dress)";
         cout<<setw(17)<<"$3550.75"<<endl;
       cout<<"Futons(10 beds)";
         cout<<setw(25)<<"$10250.60"<<endl;
       cout<<"Electricity Fee";
         cout<<setw(24)<<"$7550.75"<<endl;
      
      total3=Service+Hanbok+Futons+Elec;
      cout<<"Total of extra fee is: "<<setw(9)<<"$"<<total3<<endl;
      
      Total=days*total3;
      cout<<"The total amount is: "<<setw(11)<<"$"<<Total<<endl;
      system ("pause");
       system("cls");
       cout<<"Arigatou gozaimasu! Thank you for choosing Happy Island Resort."<<endl;
       cout<<"We hope you enjoyed your stay and experienced Japan's Culture"<<endl;
            
   }
      break;
      
}
    }
    else if ( ch == 'K' || ch == 'k')
    {
      cout<<"Types of room:"<<endl;
      cout<<"\t[1] SHINee Room \n";
      cout<<"\t[2] Sone Room \n";
      cout<<"\t[3] Primadonna Room \n";
      cout<<"What is the type of room? ";
      cin>>room;
      cout<<"How many days? ";
      cin>>days;
      switch(room)
   {
   
   
   case 1:
      {
      
      const double Service=2550.75, Hanbok=3550.75,Futons=5000.50, Elec=4500.75;
      int total1;
        cout<<"Service Charge";
          cout<<setw(25)<<"$2550.75"<<endl;
       cout<<"Hanbok(Korean Dress)";
          cout<<setw(19)<<"$3550.75"<<endl;
       cout<<"Ibul (5 beds)";
          cout<<setw(26)<<"$5000.50"<<endl;
       cout<<"Electricity Fee";
          cout<<setw(24)<<"$4500.75"<<endl;
       total1=Service+Hanbok+Futons+Elec;
       cout<<setprecision(10)<<"Total of extra fee is: "<<setw(9)<<"$"<<total1<<endl;
        Total=days*total1;
        cout<<"The total amount is: "<<setw(11)<<"$"<<Total<<endl;
       system ("pause");
       system("cls");
       cout<<"Kamsahamnida! Thank you for choosing Happy Island Resort."<<endl;
       cout<<"We hope you enjoyed your stay and experienced Korea's Culture"<<endl;
    }
       break;
   case 2:
      {
      double Service = 2550.75,Hanbok = 3550.75,Futons = 8000.50, Elec = 4500.75, total2;
         cout<<"Service Charge";
          cout<<setw(25)<<"$2550.75"<<endl;
       cout<<"Hanbok(Korean Dress)";
          cout<<setw(19)<<"$3550.75"<<endl;
       cout<<"Ibul (8 beds)";
          cout<<setw(26)<<"$8000.60"<<endl;
       cout<<"Electricity Fee";
          cout<<setw(24)<<"$4500.75"<<endl;
      
       total2=Service+Hanbok+Futons+Elec;
       cout<<"Total of extra fee is: "<<setw(9)<<"$"<<total2<<endl;
      
      Total=days*total2;
      cout<<"The total amount is: "<<setw(11)<<"$"<<Total<<endl;
      system ("pause");
       system("cls");
       cout<<"Kamsahamnida! Thank you for choosing Happy Island Resort."<<endl;
       cout<<"We hope you enjoyed your stay and experienced Korea's Culture"<<endl;
      }
      break;
   case 3:
      {
      
      double Service = 2550.75, Hanbok = 3550.75, Futons = 10250.60, Elec = 7550.75, total3;
      cout<<"Service Charge";
         cout<<setw(25)<<"$2550.75"<<endl;
       cout<<"Hanbok(Korean Dress)";
         cout<<setw(19)<<"$3550.75"<<endl;
       cout<<"Ibul(10 beds)";
         cout<<setw(25)<<"$10250.60"<<endl;
       cout<<"Electricity Fee";
         cout<<setw(24)<<"$7550.75"<<endl;
      
      total3=Service+Hanbok+Futons+Elec;
      cout<<"Total of extra fee is: "<<setw(9)<<"$"<<total3<<endl;
      
      Total=days*total3;
      cout<<"The total amount is: "<<setw(11)<<"$"<<Total<<endl;
      system ("pause");
       system("cls");
       cout<<"Kamsahamnida! Thank you for choosing Happy Island Resort."<<endl;
       cout<<"We hope you enjoyed your stay and experienced Korean's Culture"<<endl;
            
   }
      break;
      
}
    }
       cout<<setw(60)<<"**********Happy Island Resort**********"<<endl;
      system("pause>0");
   
   
      return 0;
}

//Pano yung babalik yung program sa simula? Yung mamimili ka ulit sa choices. Last na po yan TY :)

golgo13

  • Active - Two Stars
  • **
  • Posts: 207
  • Karma 22
Re: Help about sa Looping
« Reply #1 on: September 02, 2013, 10:36:49 pm »
lagyan mo goto statement

ichiraku

  • Webmasters/Programmer
  • Active - Top Level
  • *
  • Posts: 641
  • Karma 43
  • Now you see me, now you dont.
Re: Help about sa Looping
« Reply #2 on: September 02, 2013, 10:41:06 pm »
goto or while loop.

Kik0y_Dakila

  • Malibog man daw at Magaling.. Nakakaraos din..
  • Pioneer
  • Active - Top Level
  • *
  • Posts: 875
  • Karma 13
  • Gender: Male
  • 8s nt d size tht counts.8s d performans tht counts
Re: Help about sa Looping
« Reply #3 on: September 02, 2013, 11:58:57 pm »
gumawa ka another option: "Another transaction?" [y][n]

loop ka with go to..

BebeAdik

  • Active - First Star
  • *
  • Posts: 70
  • Karma 0
  • Once a Adik always an Adik!
Re: Help about sa Looping
« Reply #4 on: September 03, 2013, 12:36:52 am »
San ilalagay ? atsaka ano ilalagay sa expression ?

golgo13

  • Active - Two Stars
  • **
  • Posts: 207
  • Karma 22
Re: Help about sa Looping
« Reply #5 on: September 03, 2013, 04:17:17 am »
tama ung sabi ni Kik0y_Dakila

lagyan ng "Another transaction?" [y][n]

then lagay mo lahat sa every case mo

tsukune

  • 2008 Guardians
  • Active - First Star
  • *
  • Posts: 78
  • Karma 0
Re: Help about sa Looping
« Reply #6 on: September 05, 2013, 12:16:27 am »
gamit ka ng while o kaya do while loop
ito try mo
#include <cstdlib>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
      int days, Total;
      char ch;
   char choice ; storage ng y at n
   int room;
do{
      cout<<setw(60)<<"**********Happy Island Resort**********"<<endl;
      cout<<"\t[J] Japan \n";
      cout<<"\t[K] Korea \n";
      cout<<"Where did you stay? "<<endl;
      cin>>ch;
   
   if(ch == 'J' || ch == 'j')
   {
      cout<<"Types of room:"<<endl;
      cout<<"\t[1] Aincrad Room \n";
      cout<<"\t[2] Fairy Tail Room \n";
      cout<<"\t[3] Shiganshina Room \n";
      cout<<"What is the type of room? ";
      cin>>room;
      cout<<"How many days? ";
      cin>>days;
           
      switch(room)
   {
   
   
   case 1:
      {
      
         float SAO[4]={2550.75,3550.75,5000.50, 4500.75};
      int total1;
        cout<<"Service Charge";
          cout<<setw(25)<<"$2550.75"<<endl;
       cout<<"Kimono(Japanese Dress)";
          cout<<setw(17)<<"$3550.75"<<endl;
       cout<<"Futons(5 beds)";
          cout<<setw(25)<<"$5000.50"<<endl;
       cout<<"Electricity Fee";
          cout<<setw(24)<<"$4500.75"<<endl;
       total1=SAO[0]+SAO[1]+SAO[2]+SAO[3];
       cout<<setprecision(10)<<"Total of extra fee is: "<<setw(9)<<"$"<<total1<<endl;
        Total=days*total1;
        cout<<"The total amount is: "<<setw(11)<<"$"<<Total<<endl;
       system ("pause");
       system("cls");
       cout<<"Arigatou gozaimasu! Thank you for choosing Happy Island Resort."<<endl;
       cout<<"We hope you enjoyed your stay and experienced Japan's Culture"<<endl;
    }
       break;
   case 2:
      {
      double Service = 2550.75,Hanbok = 3550.75,Futons = 8000.50, Elec = 4500.75, total2;
         cout<<"Service Charge";
          cout<<setw(25)<<"$2550.75"<<endl;
       cout<<"Kimono(Japanese Dress)";
          cout<<setw(17)<<"$3550.75"<<endl;
       cout<<"Futons(8 beds)";
          cout<<setw(25)<<"$8000.60"<<endl;
       cout<<"Electricity Fee";
          cout<<setw(24)<<"$4500.75"<<endl;
      
       total2=Service+Hanbok+Futons+Elec;
       cout<<"Total of extra fee is: "<<setw(9)<<"$"<<total2<<endl;
      
      Total=days*total2;
      cout<<"The total amount is: "<<setw(11)<<"$"<<Total<<endl;
      system ("pause");
       system("cls");
       cout<<"Arigatou gozaimasu! Thank you for choosing Happy Island Resort."<<endl;
       cout<<"We hope you enjoyed your stay and experienced Japan's Culture"<<endl;
      }
      break;
   case 3:
      {
      
      double Service = 2550.75, Hanbok = 3550.75, Futons = 10250.60, Elec = 7550.75, total3;
      cout<<"Service Charge";
         cout<<setw(25)<<"$2550.75"<<endl;
       cout<<"Kimono(Korean Dress)";
         cout<<setw(17)<<"$3550.75"<<endl;
       cout<<"Futons(10 beds)";
         cout<<setw(25)<<"$10250.60"<<endl;
       cout<<"Electricity Fee";
         cout<<setw(24)<<"$7550.75"<<endl;
      
      total3=Service+Hanbok+Futons+Elec;
      cout<<"Total of extra fee is: "<<setw(9)<<"$"<<total3<<endl;
      
      Total=days*total3;
      cout<<"The total amount is: "<<setw(11)<<"$"<<Total<<endl;
      system ("pause");
       system("cls");
       cout<<"Arigatou gozaimasu! Thank you for choosing Happy Island Resort."<<endl;
       cout<<"We hope you enjoyed your stay and experienced Japan's Culture"<<endl;
            
   }
      break;
      
}
    }
    else if ( ch == 'K' || ch == 'k')
    {
      cout<<"Types of room:"<<endl;
      cout<<"\t[1] SHINee Room \n";
      cout<<"\t[2] Sone Room \n";
      cout<<"\t[3] Primadonna Room \n";
      cout<<"What is the type of room? ";
      cin>>room;
      cout<<"How many days? ";
      cin>>days;
      switch(room)
   {
   
   
   case 1:
      {
      
      const double Service=2550.75, Hanbok=3550.75,Futons=5000.50, Elec=4500.75;
      int total1;
        cout<<"Service Charge";
          cout<<setw(25)<<"$2550.75"<<endl;
       cout<<"Hanbok(Korean Dress)";
          cout<<setw(19)<<"$3550.75"<<endl;
       cout<<"Ibul (5 beds)";
          cout<<setw(26)<<"$5000.50"<<endl;
       cout<<"Electricity Fee";
          cout<<setw(24)<<"$4500.75"<<endl;
       total1=Service+Hanbok+Futons+Elec;
       cout<<setprecision(10)<<"Total of extra fee is: "<<setw(9)<<"$"<<total1<<endl;
        Total=days*total1;
        cout<<"The total amount is: "<<setw(11)<<"$"<<Total<<endl;
       system ("pause");
       system("cls");
       cout<<"Kamsahamnida! Thank you for choosing Happy Island Resort."<<endl;
       cout<<"We hope you enjoyed your stay and experienced Korea's Culture"<<endl;
    }
       break;
   case 2:
      {
      double Service = 2550.75,Hanbok = 3550.75,Futons = 8000.50, Elec = 4500.75, total2;
         cout<<"Service Charge";
          cout<<setw(25)<<"$2550.75"<<endl;
       cout<<"Hanbok(Korean Dress)";
          cout<<setw(19)<<"$3550.75"<<endl;
       cout<<"Ibul (8 beds)";
          cout<<setw(26)<<"$8000.60"<<endl;
       cout<<"Electricity Fee";
          cout<<setw(24)<<"$4500.75"<<endl;
      
       total2=Service+Hanbok+Futons+Elec;
       cout<<"Total of extra fee is: "<<setw(9)<<"$"<<total2<<endl;
      
      Total=days*total2;
      cout<<"The total amount is: "<<setw(11)<<"$"<<Total<<endl;
      system ("pause");
       system("cls");
       cout<<"Kamsahamnida! Thank you for choosing Happy Island Resort."<<endl;
       cout<<"We hope you enjoyed your stay and experienced Korea's Culture"<<endl;
      }
      break;
   case 3:
      {
      
      double Service = 2550.75, Hanbok = 3550.75, Futons = 10250.60, Elec = 7550.75, total3;
      cout<<"Service Charge";
         cout<<setw(25)<<"$2550.75"<<endl;
       cout<<"Hanbok(Korean Dress)";
         cout<<setw(19)<<"$3550.75"<<endl;
       cout<<"Ibul(10 beds)";
         cout<<setw(25)<<"$10250.60"<<endl;
       cout<<"Electricity Fee";
         cout<<setw(24)<<"$7550.75"<<endl;
      
      total3=Service+Hanbok+Futons+Elec;
      cout<<"Total of extra fee is: "<<setw(9)<<"$"<<total3<<endl;
      
      Total=days*total3;
      cout<<"The total amount is: "<<setw(11)<<"$"<<Total<<endl;
      system ("pause");
       system("cls");
       cout<<"Kamsahamnida! Thank you for choosing Happy Island Resort."<<endl;
       cout<<"We hope you enjoyed your stay and experienced Korean's Culture"<<endl;
            
   }
      break;
      
}
    }
cout<<"Another transaction? [y][n]"; //backslash e
cin>>choice;
}while(choice =='Y' || choice =='y');

       cout<<setw(60)<<"**********Happy Island Resort**********"<<endl;
      system("pause>0");
   
   
      return 0;
}

//Pano yung babalik yung program sa simula? Yung mamimili ka ulit sa choices. Last na po yan TY :)