Specifies the Day of the input numbers

Analysis Program :
This program to find out the name of the day if we input the number. The process uses a switch case. We can input the numbers 1 through 7. If more than 7 or 0, then the program can not determine because already know right? Yes. Because there are only 7 days a week

Program :


#include <iostream.h>

class HARI {
public:
  hari();
private:
  int dino;
  };
HARI::hari() {
cout<<"Masukan angka =  ";
cin>>dino;
  switch (dino) {
    case 1:
    cout<<"Hari ke : "<<dino<<" = Senin";break;
    case 2:
   cout<<"Hari ke : "<<dino<<" = Selasa";break;
    case 3:
   cout<<"Hari ke : "<<dino<<" = Rabu";break;
    case 4:
    cout<<"Hari ke : "<<dino<<" = Kamis";break;
    case 5:
    cout<<"Hari ke : "<<dino<<" = Jumat";break;
    case 6:
    cout<<"Hari ke : "<<dino<<" = Sabtu";break;
    case 7:
    cout<<"Hari ke : "<<dino<<" = Minggu";break;
    default:
   cout<<"Inputan eror, hanya 1 sampai 7 !!!";break;
    }
    }

main(){
  HARI x;
  x.hari();
}

Iklan

Posted on April 17, 2011, in Alprog. Bookmark the permalink. Tinggalkan komentar.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout /  Ubah )

Foto Google+

You are commenting using your Google+ account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )

w

Connecting to %s

%d blogger menyukai ini: