Responsi Praktikum DKP
1. Membuat program Tabel Konversi Suhu menggunakan perulangan (FOR)
Listing Program:
2. Membuat program Konversi Mata Uang menggunakan percabangan (SWITCH)
Listing Program:
a.
b.
Listing Program:
#include<iostream.h> #include<stdio.h> main() { int i; float c=0, f, r, k; cout<< " ======================================\n "; cout<< "Nama\t: Ashadi Setiawan \n"; cout<< " NIM\t: 1700022036 \n"; cout<< " ======================================\n "; cout<< "\t\tKONVERSI SUHU\n "; cout<< "======================================\n "; cout<< " C F R K\n"; for(i=1; i<=15; i++) { c=c+7; f=c*1.8+32; r=c*0.8; k=c+273.25; printf(" %7.0f %7.1f %7.2f %7.3f\n",c ,f ,r ,k); } cout<< " ======================================\n "; return 0; }Hasil Program:
2. Membuat program Konversi Mata Uang menggunakan percabangan (SWITCH)
Listing Program:
#include<iostream.h> main() { int pilihan; float uang, konversi; cout<< " ======================================\n "; cout<< "Nama\t: Ashadi Setiawan\n"; cout<< " NIM\t: 1700022036\n"; cout<< " ======================================\n "; cout<< "\tKONVERSI MATA UANG\n "; cout<< "======================================\n "; cout<< "Masukkan nilai mata uang:\n "; cin>>uang; cout<< " ======================================\n "; cout<< "\tMENU KONVERSI\n "; cout<< "1. Konversi IDR to USD\n "; cout<< "2. Konversi USD to IDR\n "; cout<< "======================================\n "; cout<< "Masukkan pilihan: "; cin>>pilihan; switch (pilihan) { case 1: { konversi=uang/13000; cout<< " ======================================\n "; cout<< "Hasil konversi IDR ke USD:\n "; cout<< "IDR "<<uang<<" = $ "<<konversi<<endl; cout<< " ======================================\n "; } break; case 2: { konversi=uang*13000; cout<< " ======================================\n "; cout<<" Hasil konversi USD ke IDR:\n "; cout<< "USD "<<uang<<" = IDR "<<konversi<<endl; cout<< " ======================================\n "; } break; case 3: { cout<< "Pilihan tidak tersedia "; } break; } }Hasil Program:
a.
b.
Tidak ada komentar