Merubah Nilai ke Huruf

Analysis program :
The program is to convert a numeric value to lower case by using the function if else. Using the integer data type as input the numerical value and char data type with the output value.


#include <iostream.h>

class nilai {
public :
  void masukan();
  void proses();
private:
  int nilai;
  char hasil;};
void nilai::masukan() {
  cout<<"Masukkan Angka : ";cin>>nilai;}
void nilai::proses() {
     if ((nilai>0) && (nilai <=20))
        cout<<" hurufnya : E"<<endl;
     else if ((nilai>20) && (nilai <=40))
        cout<<" hurufnya : D"<<endl;
     else if ((nilai>40) && (nilai <=60))
        cout<<" hurufnya : C"<<endl;
     else if ((nilai>60) && (nilai <=80))
        cout<<" hurufnya : B"<<endl;
     else if ((nilai>80) && (nilai <=100))
        cout<<" hurufnya : A"<<endl;
        else
          cout<<"Angka tidak ada inputannya harus 0-100 !!!"<<endl;}
int main(){
  nilai x;
  x.masukan();
  x.proses();
getch();
}

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: