Mesran

Hanya ingin berbagi kebaikan dan mendapatkan kebaikan yang lain.

Jawaban Ujian : Bahasa C++ Type C

Berikut merupakan jawaban ujian Pemrograman Terstruktur menggunakan Bahasa C++ dengan tipe soal C.

Berikut ini listing programnya :

#include "conio.h"
#include "iostream.h"
#include "string.h"
struct dataproduk{
	int kode ;
	int jumlah ;
} recproduk[10] ;

void main() {
	long harga ;
	int hasil ;
	long tharga, tbayar ;
	float fdisc ;
	float disc ;
	char pil ;
	char nama[20];
	int j, i=0 ;
	pil='Y' ;

	while(pil=='Y'||pil=='y'){
		  clrscr() ;
		  gotoxy(30,4) ; cout<< "Inputkan Kode Produk[1,2,3]"  ;
		  gotoxy(30,5) ; cout<< "---------------------------"  ;
		  gotoxy(30,6) ; cout<< "Kode  : "  ; cin >> recproduk[i].kode ;
		  gotoxy(30,7) ; cout<< "Jumlah: "  ; cin >> recproduk[i].jumlah ;
		  gotoxy(30,9) ; cout<< "Input Data Lagi : "  ; pil = getch() ;
		  i++ ;
	}
	clrscr() ;
	gotoxy(2,2) ; cout<< "PT. SMARTPROG"  ;
	gotoxy(2,3) ; cout<< "Laporan Penjualan Produk"  ;
	gotoxy(2,4) ; cout<< "-----------------------------------------------------------------------------"  ;
	gotoxy(2,5) ; cout<< "No Kode Nama Produk   Harga     Jumlah Discount   Total Harga  Total Bayar"  ;
	gotoxy(2,6) ; cout<< "-----------------------------------------------------------------------------"  ;
	for(j=0 ; j<i ; j++){
		  if(recproduk[j].kode==101){
				strcpy(nama,"Televisi") ;
				harga = 1700000 ;
				fdisc = 0.02 ;
		  }else if(recproduk[j].kode==102){
				strcpy(nama,"DVD Player") ;
				harga = 750000 ;
				fdisc = 0.05 ;
		  }else if(recproduk[j].kode==103){
				strcpy(nama,"CD Room") ;
				harga = 450000 ;
				fdisc = 0.025 ;
		  }else{
				strcpy(nama,"----") ;
				harga = 0 ;
				fdisc = 0 ;
		  }

		  if(recproduk[j].jumlah > 2){
					disc = fdisc * (harga * recproduk[j].jumlah) ;
		  }else
					disc = 0 ;

		  tharga = harga * recproduk[j].jumlah ;
		  tbayar = tharga - disc ;

		  gotoxy(3,7+j) ; cout<< j+1 << " " << recproduk[j].kode ;
		  gotoxy(10,7+j) ; cout<< nama  ;
		  gotoxy(22,7+j) ; cout<< harga ;
		  gotoxy(35,7+j) ; cout<< recproduk[j].jumlah;
		  gotoxy(41,7+j) ; cout<< disc;
		  gotoxy(52,7+j) ; cout<< tharga;
		  gotoxy(65,7+j) ; cout<< tbayar;
	}
	gotoxy(2,8+j) ; cout<< "-----------------------------------------------------------------------------"  ;

}:D
Advertisements

Filed under: C/C++, Ujian, ,

Terima kasih telah memberikan komentar anda.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Archives Per Tahun

%d bloggers like this: