Contoh Soal UAS 1

Tampilan Input :










Tampilan Output:











Script:
#include<conio.h>
#include<stdio.h>
#include<iostream.h>

char *bakso(int kobak)
{
if(kobak==1)
{return "Bakso Telor";}
else
if
(kobak==2)
{return "Bakso Urat";}
else
if
(kobak==3)
{return "Bakso Tenis";}
}


int habak(int kobak)
{
if
(kobak==1)
{return 20000;}
else
if
(kobak==2)
{return 25000;}
else
if
(kobak==3)
{return 30000;}
}


char *minuman(int komin)
{
if
(komin==1)
{return "Teh Botol";}
else
if
(komin==2)
{return "Fanta";}
else
if
(komin==3)
{return "Coca-Cola";}
}


int hamin(int komin)
{
if
(komin==1)
{return 7000;}
else
if
(komin==2)
{return 7500;}
else
if
(komin==3)
{return 8000;}
}


struct
{

char bakso,minuman;
int habak,kobak,komin,hamin,totbak,totmin,jubak,jumin,subtotal;
}reot[10];

main()
{
char nama[20],lagi;
int data,total=0,jumbay,kembalian,i;

atas:
clrscr();

cout<<"**********************************************"<<endl;
cout<<"***************Saung Bakso Reot***************"<<endl;
cout<<"**********************************************"<<endl;
cout<<"Masukkan Nama Pembeli      : ";gets(nama);
cout<<"Masukkan Jumlah data       : ";cin>>data;
cout<<"**********************************************"<<endl;
for(i=1;i<=data;i++)
{
cout<<"Data Ke-"<<i<<endl;
cout<<"Kode Porsi [1/2/3]         : ";cin>>reot[i].kobak;
cout<<"Jumlah Porsi Bakso         : ";cin>>reot[i].jubak;
cout<<"Kode Minuman [1/2/3]       : ";cin>>reot[i].komin;
cout<<"Jumlah Beli Minuman        : ";cin>>reot[i].jumin;
cout<<"**********************************************"<<endl;

reot[i].totbak=habak(reot[i].kobak)*reot[i].jubak;
reot[i].totmin=hamin(reot[i].komin)*reot[i].jumin;
reot[i].subtotal=reot[i].totbak+reot[i].totmin;
total=total+reot[i].subtotal;
}
clrscr();

cout<<"**********************************************************************************************"<<endl;
cout<<"************************************Saung Bakso Reot******************************************"<<endl;
cout<<"**********************************************************************************************"<<endl;
cout<<"No. Nama         Harga   Jumlah    Nama        Harga     Jumlah    Total     Total    Subtotal"<<endl;
cout<<"    Bakso        Bakso   Bakso    Minuman     Minuman   Minuman    Bakso    Minuman           "<<endl;
cout<<"**********************************************************************************************"<<endl;
for(i=1;i<=data;i++)
{
gotoxy(1,7+i);cout<<i;
gotoxy(5,7+i);cout<<bakso(reot[i].kobak);
gotoxy(18,7+i);cout<<habak(reot[i].kobak);
gotoxy(28,7+i);cout<<reot[i].jubak;
gotoxy(35,7+i);cout<<minuman(reot[i].komin);
gotoxy(48,7+i);cout<<hamin(reot[i].komin);
gotoxy(60,7+i);cout<<reot[i].jumin;
gotoxy(68,7+i);cout<<reot[i].totbak;
gotoxy(77,7+i);cout<<reot[i].totmin;
gotoxy(87,7+i);cout<<reot[i].subtotal<<endl;
}
cout<<"**********************************************************************************************"<<endl;
cout<<"Total Pendapatan   : "<<total<<endl;
cout<<"Jumlah Bayar       : ";cin>>jumbay;
kembalian=jumbay-total;
cout<<"kembalian          : "<<kembalian<<endl;
cout<<"**********************************************************************************************"<<endl;
cout<<"Input Data Lagi [Y/T]...? ";cin>>lagi;
if(lagi=='Y'||lagi=='y')
{goto atas;}
getch();
}

My Facebook :      My Twitter :
       

2 komentar:

desi lisandi mengatakan...

terimakasih ya, sangat membantu :)

agil gila mengatakan...

tengkyu gan, ane lagi cari latihan uas nih. gbu.. tambah lagi kalo bisa

Poskan Komentar

BLOG TUGAS BSI 22 BY: NICO SAVERO