Tugas Pertemuan 5 Algoritma dan Struktur data
ASSALAMUALAIKUM WR WB
Nama: Raihan Fajarahmatan
Nim: 3420210010
Prodi: Teknik Informatika
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
/*
//Nama : Raihan Fajarahmatan
//NIM : 3420210010
//Prodi : Teknik Informatika
*/
void main()
{
char kode,lagi;
//Deklarasi Label
atas:
clrscr();
cout<<"MASUKKAN KODE BARANG [A/B/C]: ";
kode = getche();
cout<<'\n';
switch (kode) {
case 'A' : case 'a':
cout<<"Alat Musik"; break;
case 'B' : case 'b':
cout<<"Alat Laboratorium"; break;
case 'C' : case 'c':
cout<<"Alat Dapur"; break;
default:
cout<<"Anda Salah Memasukan Kode";
}
cout<<'\n';
cout<<"\nIngin Pilih Lagi [Y/N]: ";
lagi = getche();
if(lagi == 'Y' || lagi == 'y') goto atas;
getch();
}
Lampiran Tugas 5.2
pseudo code in Borland C++
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
/*
//Nama:Raihan Fajarahmatan
//NIM :3420210010
//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,"Pencari Kitab Suci");harga=50000;
break;
case '2':
strcpy(nama,"Kegagalan Awal Kesuksesan");
harga=75000;
break;
default:
strcpy(nama,"Kekuasaan Diatas Segalanya");
harga=55000;
}
total = harga * jml; ppn = 0.1 * total;
if(jml>10) {
strcpy(bonus,"Jalan Jalan Ke Bali");
pot = 0.1 * total;
}
else {
strcpy(bonus,"Maaf Tidak Dapat Bonus");
pot = 0;
}
grand = total + ppn - pot;
clrscr();
puts(" ***TOKO BUKU PAK JENGGOT***");
puts(" Jl.Spontan No.1A");
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 Pesan Lagi...?";cin>>lagi;
if (lagi == 'Y' || lagi=='y') {goto lagi; }
getch();
{
pseudo code in Borland C++
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
/*
//Nama : Raihan Fajarahmatan
//NIM :3420210010
//Prodi :Teknik Infomartika
*/
void main()
{
char nama[50],tipe[50],souvenir[50];
char kode,lagi;
int lama;
float harga,total,admin=225000,ubay,ukem;
awal:
clrscr();
puts("HOTEL PUNYA PAK SELAMET");
puts("********************************");
cout<<"Nama Penyewa : ";cin>>nama;
cout<<"Kode Kamar [A/B/C]: ";cin>>kode;
if (kode == 'A' || kode == 'a')
{
strcpy(tipe,"AC+TV");
harga = 250000;
}
else if (kode == 'B' || kode == 'b')
{
strcpy(tipe,"AC DOANG");
harga = 150000;
}
else if (kode == 'C' || kode == 'c')
{
strcpy(tipe,"KIPAS DOANG");
harga = 70000;
}
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("HOTEL PUNYA PAK SELAMET");
puts("******************************");
cout<<"Nama Penyewa : "<<nama<<endl;
cout<<"Kode Kamar [A/B/C]: "<<kode<<endl;
cout<<"Lama Menginap : ";cin>>lama;
puts("******************************");
if (lama>=10)
{
strcpy(souvenir,"Korek Cricket");
}
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.5f \n",harga);
printf("Biaya Administrasi \t: Rp.%2.5f \n",admin);
printf("Total Biaya Sewa \t: Rp.%2.5f \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();
}
SEKIAN DAN TERIMA KASIH
WASSALAMUALAIKUM WR WB
Komentar
Posting Komentar