Nah kalau yang ini merupakan pembahasan ujian tipe A.
Listing Programnya.
#include "conio.h" #include "stdio.h" #include "iostream.h" #include "string.h" struct datarumah{ char nama[30]; char tipe[3] ; double uang ; int jumlah ; } recrumah[10] ; void main() { long harga ; int hasil ; double tharga, sisa ; char pil ; char nama[20]; int j, i=0 ; pil='Y' ; while(pil=='Y'||pil=='y'){ clrscr() ; gotoxy(30,4) ; cout<< "Inputkan Rumah" ; gotoxy(30,5) ; cout<< "---------------------------" ; gotoxy(30,6) ; cout<< "Nama Pembeli : " ; cin >> recrumah[i].nama ; gotoxy(30,7) ; cout<< "Tipe Rumah : " ; cin >> recrumah[i].tipe ; gotoxy(30,8) ; cout<< "Jumlah : " ; cin >> recrumah[i].jumlah; gotoxy(30,9) ; cout<< "Uang Muka : " ; cin >> recrumah[i].uang; gotoxy(30,11); cout<< "Input Data Lagi : " ; pil = getch() ; i++ ; } clrscr() ; gotoxy(2,2) ; cout<< "PT. SMARTHOME" ; gotoxy(2,3) ; cout<< "Laporan Penjualan Rumah" ; gotoxy(2,4) ; cout<< "-------------------------------------------------------------------------------" ; gotoxy(2,5) ; cout<< "No Nama Type Keterangan Harga Jumlah Uang Muka Sisa Pembayaran " ; gotoxy(2,6) ; cout<< "-------------------------------------------------------------------------------" ; for(j=0 ; j<i ; j++){ strcpy(nama,"---") ; harga = 0 ; hasil = strcmp(recrumah[j].tipe,"R21") ; if(hasil==0){ strcpy(nama,"Rumah KT2&KM1") ; harga = 60000000 ; } hasil = strcmp(recrumah[j].tipe,"R31") ; if(hasil==0){ strcpy(nama,"Rumah KT3&KM1") ; harga = 80000000 ; } hasil = strcmp(recrumah[j].tipe,"R32") ; if(hasil==0){ strcpy(nama,"Rumah KT3&KM2") ; harga = 95000000 ; } tharga = harga * recrumah[j].jumlah ; sisa = tharga - recrumah[j].uang ; gotoxy(3,7+j) ; cout<< j+1 << " " << recrumah[j].nama ; gotoxy(16,7+j) ; cout<< recrumah[j].tipe ; gotoxy(22,7+j) ; cout<< nama ; gotoxy(37,7+j) ; cout<< harga; gotoxy(47,7+j) ; cout<< recrumah[j].jumlah ; gotoxy(54,7+j) ; cout<< recrumah[j].uang ; gotoxy(66,7+j) ; cout<< sisa ; } gotoxy(2,8+j) ; cout<< "-------------------------------------------------------------------------------" ; }
Advertisements