#include <cstdlib> |
#include <iostream> |
using namespace std; |
class Nilai{ |
friend ostream& operator<<(ostream&,Nilai&); |
friend istream& operator>>(istream&,Nilai&); |
public: |
Nilai(){}; |
void konversikan(){ |
if((nilai>0)&&(nilai<=20)) |
nilai_huruf='E'; |
else if((nilai > 20)&&(nilai<=40)) |
nilai_huruf='D'; |
else if((nilai > 40)&&(nilai<=60)) |
nilai_huruf='C'; |
else if((nilai>60)&&(nilai<=80)) |
nilai_huruf='B'; |
else nilai_huruf='A'; |
} |
private: |
int nilai; |
char nilai_huruf; |
}; |
istream& operator>>(istream& in,Nilai& masukan){ |
cout<<"MASUKKAN NILAI = "; |
in>>masukan.nilai; |
return in; |
}; |
ostream& operator<<(ostream& out,Nilai&keluaran){ |
out<<"NILAI HURUF = "<<keluaran.nilai_huruf; |
return out; |
}; |
int main() |
{ |
Nilai angka; |
cin>>angka; |
angka.konversikan(); |
cout<<angka; |
system("PAUSE"); |
return EXIT_SUCCESS; |
} |
Selasa, 29 Maret 2011
NILAI KE HURUF
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar