Contoh Soal UAS C++



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

main()
{
class
{

public:
int
kopaket,harga,jumbel,subtotal;
char kokelas,*kelas;
}travel[15];

char nama[20],lagi;
int data,jumyar,kembali,total=0,i;

atas:
clrscr();
cout<<"Masukan jumlah Data         : ";cin>>data;
clrscr();
cout<<"Masukkan Nama Pembeli       : ";gets(nama);
for(i=1;i<=data;i++)
{
cout<<"data ke-"<<i<<endl;
cout<<"Paket Travel [1/2/3]        : ";cin>>travel[i].kopaket;
cout<<"Kode Kelas [A/B/C]          : ";cin>>travel[i].kokelas;
cout<<"Jumlah Beli                 : ";cin>>travel[i].jumbel;

if(travel[i].kopaket==1)
{
if(travel[i].kokelas=='A'||travel[i].kokelas=='a')
{travel[i].kelas="VIP";
travel[i].harga=2500000;}
else
if
(travel[i].kokelas=='B'||travel[i].kokelas=='b')
{travel[i].kelas="Eksekutif";
travel[i].harga=1800000;}
else
if(travel[i].kokelas=='C'||travel[i].kokelas=='c')
{travel[i].kelas="Ekonomi";
travel[i].harga=1000000;}
}
elseif(travel[i].kopaket==2)
{
if(travel[i].kokelas=='A'||travel[i].kokelas=='a')
{travel[i].kelas="VIP";
travel[i].harga=5000000;}
else
if
(travel[i].kokelas=='B'||travel[i].kokelas=='b')
{travel[i].kelas="Eksekutif";
travel[i].harga=3000000;}
else
if(travel[i].kokelas=='C'||travel[i].kokelas=='c')
{travel[i].kelas="Ekonomi";
travel[i].harga=1500000;}
}
else
if(travel[i].kopaket==3)
{
if(travel[i].kokelas=='A'||travel[i].kokelas=='a')
{travel[i].kelas="VIP";
travel[i].harga=1500000;}
else
if
(travel[i].kokelas=='B'||travel[i].kokelas=='b')
{travel[i].kelas="Eksekutif";
travel[i].harga=1000000;}
else
if(travel[i].kokelas=='C'||travel[i].kokelas=='c')
{travel[i].kelas="Ekonomi";
travel[i].harga=750000;}
}

travel[i].subtotal=travel[i].harga*travel[i].jumbel;
total=total+travel[i].subtotal;

}
clrscr();
cout<<"Nama Pembeli : "<<nama<<endl;
cout<<"******************************************************************"<<endl<<endl;

cout<<"*********************Traveling Lang-Lang Buana********************"<<endl<<endl;

cout<<"******************************************************************"<<endl;
cout<<"No.  Kode Paket    Kelas      Harga    Jumlah Beli    Subtotal"<<endl;
for(i=1;i<=data;i++)
{
gotoxy(1,8+i);cout<<i;
gotoxy(10,8+i);cout<<travel[i].kopaket;
gotoxy(20,8+i);cout<<travel[i].kelas;
gotoxy(30,8+i);cout<<travel[i].harga;
gotoxy(45,8+i);cout<<travel[i].jumbel;
gotoxy(55,8+i);cout<<travel[i].subtotal<<endl;
}
cout<<"******************************************************************"<<endl;
cout<<"Total Pendapatan : "<<total<<endl;
cout<<"Jumlah Bayar     : ";cin>>jumyar;
kembali=jumyar-total;
cout<<"Kembalian        : "<<kembali<<endl;
cout<<"******************************************************************"<<endl;
cout<<"Input Data Lagi [Y/T]...?";cin>>lagi;
if(lagi=='Y'||lagi=='y')
{goto atas;}
getch();
}



_____________________________________________________________________

Contoh Soal UAS C++



#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();
}

Post a Comment

 
Top