Algoritma Konversi Nilai Angka ke Nilai Huruf dengan C++

Algoritma konversi
{Mengkonversikan nilai angka menjadi nilai huruf}

DEKLARASI
nilai : integer (input)

DESKRIPSI
Read (nilai)
if ((nilai>=80))
then huruf =70)and (nilai<80))
then huruf =60)and(nilai<70))
then huruf <– C

else
huruf <– D

endif
Write (huruf)

Program Algoritma Konversi

#include &amp;amp;amp;lt;cstdlib&amp;amp;amp;gt;
#include &amp;amp;amp;lt;iostream&amp;amp;amp;gt;

using namespace std;
class konversi {
public :
void input ();
void proses ();

int nilai;

};

void konversi :: input(){

cout&amp;amp;amp;lt;&amp;amp;amp;lt;&amp;amp;quot;Masukkan nilai angka : &amp;amp;quot;;
cin&amp;amp;amp;gt;&amp;amp;amp;gt;nilai;
cout&amp;amp;amp;lt;&amp;amp;amp;lt;endl;

}

void konversi :: proses() {

if ((nilai&amp;amp;amp;gt;=80))
cout&amp;amp;amp;lt;&amp;amp;amp;lt;&amp;amp;quot;Nilai huruf : A&amp;amp;quot;&amp;amp;amp;lt;&amp;amp;amp;lt;endl;

else if ((nilai&amp;amp;amp;gt;=70)&amp;amp;amp;amp;&amp;amp;amp;amp;(nilai&amp;amp;amp;lt;80))
cout&amp;amp;amp;lt;&amp;amp;amp;lt;&amp;amp;quot;Nilai huruf : B&amp;amp;quot;&amp;amp;amp;lt;&amp;amp;amp;lt;endl;

else if ((nilai&amp;amp;amp;gt;=60)&amp;amp;amp;amp;&amp;amp;amp;amp;(nilai&amp;amp;amp;lt;70))
cout&amp;amp;amp;lt;&amp;amp;amp;lt;&amp;amp;quot;Nilai huruf : C&amp;amp;quot;&amp;amp;amp;lt;&amp;amp;amp;lt;endl;

else
cout&amp;amp;amp;lt;&amp;amp;amp;lt;&amp;amp;quot;Nilai huruf : D&amp;amp;quot;&amp;amp;amp;lt;&amp;amp;amp;lt;endl;
}

int main(int argc, char *argv[])
{

konversi angka;
angka.input();
angka.proses();

system(&amp;amp;quot;PAUSE&amp;amp;quot;);
return EXIT_SUCCESS;
}
Baca Juga :   Algoritma dan Program Pombensin dengan C++