1 / 11

Latihan : 1. Analisis Kasus 2. Pngulangan

Latihan : 1. Analisis Kasus 2. Pngulangan. KU1072 Pengenalan Teknologi Informasi B Oleh : Rinaldi Munir. Soal 1. Buatlah program C++ untuk mengkonversi angka arab 1-10 menjadi angka Romawi . Jika angka yang dimasukkan diluar 1-10 maka diberikan pesan kesalahan.

caden
Download Presentation

Latihan : 1. Analisis Kasus 2. Pngulangan

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Latihan:1. AnalisisKasus2. Pngulangan KU1072 PengenalanTeknologiInformasiB Oleh: RinaldiMunir

  2. Soal 1 • Buatlah program C++ untukmengkonversiangkaarab 1-10 menjadiangkaRomawi. Jikaangka yang dimasukkandiluar 1-10 makadiberikanpesankesalahan.

  3. #include <iostream> using namespace std; int main() { intangka; switch (angka) { case 1: cout << “I”; break; case 2: cout << “II”; break; case 3: cout << “III”; break; case 4: cout << “IV”; break; case 5: cout << “V”; break; case 6: cout << “VI”; break; case 7: cout << “VII”; break; case 8: cout << “VIII”; break; case 9: cout << “IX”; break; case 10: cout << “XI”; break; default : cout << “Masukanandasalah”; break; } return 0 }

  4. Soal 2 • Buatlah program C++ untukmenghitungupahkerja per minggu. Jumlah jam kerja per mingguadalah 40 jam danupah per jam adalah Rp1000. Jikalebihdari 40 jam, makasisanyadihitunglemburdanupah per jam lembur Rp2000. Jikakurangdari 40 jam makakekurangannyadidenda Rp500/jam.

  5. #include <iostream> using namespace std; int main() { intjjk; //jumlah jam kerja intkekurangan; // kekurangan jam float upah; cout << “Masukkanjumlah jam kerja per minggu: “; cin >> jjk; if (jjk >= 40) { lembur = jjk – 40; upah = 40*1000 + lembur*2000 } else { kekurangan = 40 – jjk; upah = jjk * 1000 – kekurangan * 500; } cout << “Upah per minggu”; cout << upah; } return 0 }

  6. Soal 3 • Buatlah program C++ untukmenghitungkonversi N buahsuhudariCelciuske Fahrenheit. Nilai N dansuhudimasukkanoleh user. Contoh: N = 5 Input suhudalam C: 30, 67, 120, 88, 15

  7. #include <iostream> using namespace std; int main() { int N; //jumlahperulangan float C; // suhudalamCelcius float F; //suhudalam Fahrenheit inti; // variabelpencacahpengulangan cout << “N=?”; cin >> N; for (i=1; i<=N; i++) { cout<< “KetikkansuhudalamCelcius:”; cin >> C; F = (C * 1.8 + 32); cout << “Suhudalam Fahrenheit”; cout << F << endl; } return 0 }

  8. Soal 4 • Buatlah program C++ untukmenghitung rata-rata dari N data bilanganbulat yang dibacadari keyboard. Contoh: N = 6 Data: 5, 8, 10, 12, 4, 3 Rata-rata = (5 + 8 + 10 + 12 + 4 + 3)/6 = 42/6 = 7

  9. #include <iostream> using namespace std; int main() { int N; //banyaknya data bilanganbulat inti; // variabelpencacahpengulangan int sum; // jumlahseluruh data bilanganbulat float r; // nilai rata-rata float x; // data bilanganbulat cout << “N=?”; cin >> N; sum = 0; for (i=1; i<=N; i++) { cout << “Ketikkan data:”; cin >> x; sum = sum + x; } r = sum/N; cout << “Nilai rata-rata = ”; cout << r; return 0 }

  10. Soal 5 • Buatlah program C++ untukmenghitungmundurdari N, N – 1 , N – 2, …, 3, 2, 1, 0. Nilai N diinputkanoleh user.

  11. #include <iostream> using namespace std; int main() { int N; inti; // variabelpencacahpengulangan cout<< “N=?”; cin >> N; for (i=1; i>=0; i--) { cout << i; } return 0 }

More Related