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

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

Sponsored

C&C Online Shop

Blog Stats

  • 355,907 sejak 12 Jan 2011

User’s Online


My Music

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 223 other followers

May 2011
M T W T F S S
« Apr   Jun »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  
%d bloggers like this: