Create Menu in C++ using Do, Switch.. Case

This is the code to create menu in c++. You can create menu using do and switch..case :
#include <iostream.h>
#include <conio.h>
void main() {
 int menu,a,b,c;
 char jawab[20];

 do{
 cout<<"Silakan dipilih.."<<endl;
 cout<<"1. Segitiga"<<endl;
 cout<<"2. Segiempat"<<endl;
 cout<<"Pilihan : ";
 cin>>menu;
     clrscr();
     switch (menu) {
       case 1: cout<< "Menghitung Segitiga"<<endl;
                  cout <<"Alas : ";
               cin>>a;
               cout <<"Tinggi : ";
               cin>>b;
               cout<< "Luas : "<<(0.5*a*b);
               break;
      case 2: cout<< "Menghitung Segiempat"<<endl;
                  cout <<"Panjang : ";
               cin>>a;
               cout <<"Lebar : ";
               cin>>b;
               cout<< "Luas : "<<a*b;
              cout<<"Lanjut [Y/T] ? ";
                  cin>>jawab;
      default : cout << "Makan tu Menu"<<endl;        
       }
 }while(jawab=="T");

      getch();
}
This called by "Membuat Menu di c++" in indonesian. wohoooo :D
Previous
Next Post »