Workshop minggu 4 (soal 7)
7.Seorang dosen ingin mengkonversi nilai angka hasil ujian mahasiswa menjadi nilai huruf.
Analisis:
Mengubah menjadi nilia huruf dengan ketentuan sseperti berikut:
0-60 = E
61-70 = D
71-80 = C
81-90 = B
91-100 = A
Algoritma: Nilai_huruf
{mengubah nilai menjadi nilai huruf dengan memasukan nilai 0-60=E, 61-70=D, 71-80=C,81-90=B, 91-100=A}
Deklarasi:
x= integer (output)
Deskripsi:
read (nilai)
if (<60) x=E
else if(<70) x=D
else if(<80) x=C
else if(<90) x=B
else if(<100) x=A
write(output)
Generate c++:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string raptor_prompt_variable_zzyz;
int x;
raptor_prompt_variable_zzyz ="masukkan nilai : ";
cout << raptor_prompt_variable_zzyz << endl;
cin >> x;
if (x<60)
{ cout << "E" << endl; }
else
{
if (x<70)
{ cout << "D" << endl; }
else
{
if (x<80)
{ cout << "C" << endl; }
else
{
if (x<90)
{ cout << "B" << endl; }
else
{
if (x<100)
{ cout << "A" << endl; }
else
{
}
}
}
}
}
return 0;
}
Output :
Analisis:
Mengubah menjadi nilia huruf dengan ketentuan sseperti berikut:
0-60 = E
61-70 = D
71-80 = C
81-90 = B
91-100 = A
Algoritma: Nilai_huruf
{mengubah nilai menjadi nilai huruf dengan memasukan nilai 0-60=E, 61-70=D, 71-80=C,81-90=B, 91-100=A}
Deklarasi:
x= integer (output)
Deskripsi:
read (nilai)
if (<60) x=E
else if(<70) x=D
else if(<80) x=C
else if(<90) x=B
else if(<100) x=A
write(output)
Generate c++:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string raptor_prompt_variable_zzyz;
int x;
raptor_prompt_variable_zzyz ="masukkan nilai : ";
cout << raptor_prompt_variable_zzyz << endl;
cin >> x;
if (x<60)
{ cout << "E" << endl; }
else
{
if (x<70)
{ cout << "D" << endl; }
else
{
if (x<80)
{ cout << "C" << endl; }
else
{
if (x<90)
{ cout << "B" << endl; }
else
{
if (x<100)
{ cout << "A" << endl; }
else
{
}
}
}
}
}
return 0;
}
Output :
Komentar
Posting Komentar