corat-coret (yesa-jeje.blogspot.com)

Kamis, 31 Mei 2012

c++ :)




Tuliskan if statement untuk flowchart di atas !

Asam Basa
if (ph==7)
   cout<<"Neutral"<<endl;
else if (ph<7)
        if (ph<2)
           cout<<"Very Acidic"<<endl;
        else
           cout<<"Acidic"<<endl;
    else if (ph>12)
           cout<<"Very Alkaline"<<endl;
         else
           cout<<"Alkaline"<<endl;



Question 2
Analisa dan tuliskan if statement dari problem berikut
To be accepted, the candidate’s height has to be taller than 170cm (inclusive). The candidate should also be between the aged of 23 to 30 and a swimmer. The program should receive three inputs; height, age and swimming ability (s for swimmer and n for nonswimmer). The program will display the result of either the person is accepted or otherwise.


SELEKSI KANDIDAT
Untuk bisa lolos dalam penyeleksian kandidat, kandidat harus memenuhi persyaratan sebagai berikut:
1.      Tinggi badan lebih dari atau sama dengan 170 cm (height>=170)
2.      Umur antara 23 sampai 30 tahun (age>23 && age<30)
3.      Mampu berenang (renang==’s’)

if (height>=170 &&  age>23 && age<30 && renang=='s')
   cout<<"DITERIMA"<<endl;
else
    cout<<"TIDAK DITERIMA"<<endl;