TUGAS ALGORITMA DAN STRUKTUR DATA PERTEMUAN 5
Nama : Mahfud Muhyiddin
NIM : 3420210025
Prodi : Informatika
TUGAS 4.1
4.1.1
4.1.2
4.1.3
script tugas 4.1
#include <iostream.h>
// Nama : Mahfud Muhyiddin
// Nim : 3420210025
// Prodi : Teknik Informatika
void main()
{
char kode,lagi;
//Deklarasi Label
atas:
clrscr();
cout<<"MASUKAN KODE MENU [A/B/C]: " ;
kode = getche();
cout<<'\n';
switch (kode) {
case 'A': case 'a':
cout<<"food"; break;
case 'B': case 'b':
cout<<"Drink"; break;
case 'C': case 'c':
cout<<"Dessert"; break;
default:
cout<<"Anda Salah Memasukan Kode";
}
cout<<'\n';
cout<<"\nIngin Pilih Lagi [Y/T]: ";
lagi = getche();
if(lagi == 'Y' || lagi == 'y') goto atas;
cout<<"\nTerima Kasih ";
getch();
}
TUGAS 4.2
4.2.1
4.2.2
4.2.3
script tugas 4.2
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
//Nama : Mahfud Muhyiddin
//NIM : 3420210025
//Prodi : Teknik Informatika
void main()
{
char kode,lagi; char nama[50],bonus[50];
int jml; float harga,total,pot,ppn,grand;
lagi:
clrscr();
printf("Masukan Kode Buku [1/2/3]: ");cin>>kode;
printf("Jumlah Pembelian Buku : ");cin>>jml;
switch (kode) {
case '1':
strcpy(nama,"peaky blinders");harga=40000;
break;
case '2':
strcpy(nama,"rintik sendu");harga=60000;
break;
default:
strcpy(nama,"fuurin");harga=50000;
}
total = harga * jml; ppn = 0.1 * total;
if(jml>10) {
strcpy(bonus,"anting indah");
pot = 0.1 * total;
} else {
strcpy(bonus,"Maaf Tidak Dapat Bonus");
pot = 0;
}
grand = total + ppn - pot;
clrscr();
puts(" ***TOKO BUKU KZQMEDIA***");
puts(" Jl.jambu No.41");
puts("---------------------------------------------");
cout<<"Nama Buku : "<<nama<<endl;
cout<<"Harga Buku : "<<harga<<endl;
cout<<"Bonus : "<<bonus<<endl;
cout<<"Total Bayar : "<<total<<endl;
cout<<"Potongan : "<<pot<<endl;
cout<<"PPN : "<<ppn<<endl;
cout<<"Grand Total : "<<grand<<endl;
puts("---------------------------------------------");
puts(" ***THANK YOU***");
cout<<" Mau Order Lagi...?";cin>>lagi;
if (lagi == 'Y' || lagi=='y') {goto lagi; }
getch();
}
TUGAS 4.3
4.3.1
4.3.2
4.3.3
script tugas 4.3
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
//Nama : Mahfud Muhyiddin
//NIM : 3420210025
//Prodi : Teknik Infomartika
void main()
{
char nama[50],tipe[50],souvenir[50];
char kode,lagi;
int lama;
float harga,total,admin=200000,ubay,ukem;
awal:
clrscr();
puts(" PARADISE RESORT");
puts("********************************");
cout<<"Nama Penyewa : ";cin>>nama;
cout<<"Kode Kamar [A/B/C]: ";cin>>kode;
if (kode == 'A' || kode == 'a')
{
strcpy(tipe,"FIRST CLASS");
harga = 300000;
}
else if (kode == 'B' || kode == 'b')
{
strcpy(tipe,"SECOND CLASS");
harga = 200000;
}
else if (kode == 'C' || kode == 'c')
{
strcpy(tipe,"THIRD CLASS");
harga = 100000;
}
else
{
puts("******************************");
cout<<"Kode kamar yang anda masukan salah, ingin input lagi?";
cin>>lagi;
switch(lagi)
{
case 'Y':
case 'y':
goto awal;
default:
goto akhir;
}
}
clrscr();
puts(" PARADISE RESORT");
puts("********************************");
cout<<"Nama Penyewa : "<<nama<<endl;
cout<<"Kode Kamar [A/B/C]: "<<kode<<endl;
cout<<"Lama Menginap : ";cin>>lama;
puts("******************************");
if (lama>=7)
{
strcpy(souvenir,"Free Fast Food");
}
else
{
strcpy(souvenir,"Tidak Dapat");
}
total = (harga*lama)+admin;
cout<<"Tipe Kamar \t\t: "<<tipe<<endl;
cout<<"Lama Menginap \t\t: "<<lama<<"hari"<<endl;
cout<<"Souvenir \t\t: "<<souvenir<<endl;
printf("Biaya Sewa \t\t: Rp.%2.2f \n",harga);
printf("Biaya Administrasi \t: Rp.%2.2f \n",admin);
printf("Total Biaya Sewa \t: Rp.%2.2f \n",total);
puts("******************************");
cout<<"Uang Bayar: ";cin>>ubay;
ukem = ubay - total;
cout<<"Uang kembali:"<<ukem<<endl;
cout<<"Ingin input lagi [Y/N] ";cin>>lagi;
switch(lagi)
{
case 'Y':
case 'y':
goto awal;
default:
goto akhir;
}
akhir:
getch();
}
Komentar
Posting Komentar