Tugas Algoritma & strukur data pertemuan 5
TUGAS ALGORITMA & STRUKTUR DATA
Nama : Nasrudin
Jurusan : Teknik Informatika
Nim : 3420210031
assalamualaikum wr.wb
TUGAS 1
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
//Nama : Nasrudin
//NIM : 3420210031
//Prodi : Teknik Informatika
void main ()
{
char kode, lagi;
//Deklarasi Label
atas:
clrscr();
cout<<"Masukan Kode Jenis Pakaian [a/b/c] : ";
kode = getche ();
cout<<'\n';
switch (kode) {
case 'A': case 'a':
cout<<"flanel"; break;
case 'B': case 'b':
cout<<"Hoodi"; break;
case 'C': case 'c':
cout<<"Tshir"; break;
default:
cout<<"Anda Salah Memasukan Kode";
}
cout<<'\n';
cout<<"\nIngin Pilih Lagi [Y/T]: ";
lagi = getche();
if(lagi == 'Y' || lagi == 'y') go to atas;
getch();
}
Tugas 2
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
//Nama : Nasrudin
//NIM : 3420210031
//Prodi : Teknik Informatika
void main ()
{
char kode, lagi; char nama[50], bonus[50];
int jml; float harga, total, pot, ppn, grand;
lagi:
clrscr();
puts("=============================");
printf("Masukan Kode Buku [1/2/3]: ");cin>>kode;
printf("Jumlah Pembelian Buku : ");cin>>jml;
switch (kode) {
case '1':
strcpy(nama,"Laskar Pelangi"); harga = 60000;
break;
case '2':
strcpy(nama,"Udah Putusin Aja"); harga = 50000;
break;
default:
strcpy(nama,"Dilan 1990");
harga = 90000;
}
total = harga * jml; ppn = 0.1 * total;
if(jml>3) {
strcpy(bonus,"Buku");
pot = 0.1 * total;
} else {
strcpy(bonus,"Maaf Tidak Dapat Bonus");
pot = 0;
}
grand = total + ppn - pot;
clrscr();
puts("=========================================");
puts(" **Novel Book **");
puts(" jln tegal amba duren sawit");
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(" **Terima Kasih** ");
cout<<" Input Data Lagi...?";cin>>lagi;
if (lagi == 'y' || lagi == 'y') {goto lagi;}
getch();
}
TUGAS 3
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
//Nama : Nasrudin
//NIM : 3420210031
//Prodi : Teknik Informatika
void main ()
{
char nama[50],tipe[50],souvenir[50];
char kode, lagi;
int lama;
float harga,total,admin=250000,UDIN,ROJULLUN;
awal:
clrscr();
puts (" Nama : Nasrudin");
puts (" Nim : 3420210031");
puts ("Jurusan : Teknik Informatika");
puts ("Villa CITRA");
puts ("===================");
cout<<"Nama Penyewa : ";cin>>nama;
cout<<"Kode Kamar [A/B/C]: ";cin>>kode;
if (kode == 'A' || kode == 'a')
{
strcpy (tipe,"villa 1");
harga = 350000;
}
else if (kode == 'B' || kode == 'b')
{
strcpy (tipe,"villa 2");
harga = 200000;
}
else if (kode == 'C' || kode == 'c')
{
strcpy (tipe,"villa 3");
harga = 150000;
}
else
{
puts("====================================================");
cout<<"Kode Yang Anda Masukan Salah, Ingin Input Data Lagi?";cin>>lagi;
switch(lagi)
{
case 'Y':
case 'y':
goto awal;
default:
goto akhir;
}
}
clrscr();
puts("Villa CITRA");
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,"GELANG");
}
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.%8.2f \n",harga);
printf("Biaya Administrasi \t : Rp.%8.2f \n",admin);
printf("Total Biaya Sewa \t : Rp.%8.2f \n",total);
puts("====================");
cout<<"Uang Bayar : ";cin>>ROJULLUN;
UDIN = ROJULLUN - total;
cout<<"Uang Kembali : "<<UDIN<<endl;
cout<<"Ingin Input lagi [Y/T] ";cin>>lagi;
switch(lagi)
{
case 'Y':
case 'y':
goto awal;
default:
goto akhir;
}
akhir:
getch();
}
Komentar
Posting Komentar