Tugas 3 Algoritma dan Struktur Data
Assalamu'alaikum Wr wb
#include <stdio.h> //Nama : Mukhrodi
#include <iostream.h> //NIM : 3420210023
#include <conio.h> //Prodi : Teknik Informatika
void main ()
{
//Deklarasi Variable
int absen,tugas,uts,uas;
float total;
cout<<endl;
puts ("\t\tProgram-Menghitung-Nilai-Mahasiswa");
puts ("\t- - - - - - - - - - - - - - - - - - - - - - -");
printf ("\tMasukan Nilai Absen : ");scanf("%d",&absen);
cout <<"\tMasukan Nilai Tugas : ";cin>>tugas;
printf ("\tMasukan Nilai UTS : ");scanf("%i",&uts);
cout <<"\tMasukan Nilai UAS : ";cin>>uas;
//Peoses Perhitungan
total = (absen*0.1)+(tugas*0.2)+(uts*0.3)+(uas*0.4);
puts ("\t- - - - - - - - - - - - - - - - - - - - - - -");
cout <<"\tTotal adalah : "<<total<<" (Bentuk Tidak Terformat)\n";
printf ("\tTotal adalah : %.2f (Bentuk Yang Terformat)\n",total);
puts ("\t- - - - - - - - - - - - - - - - - - - - - - -");
//Kondisi
if (total >=75 )
{ cout <<"\tSelamat Anda Lulus."; }
else
{ cout <<"\tMaaf Anda Tidak Lulus."; }
getch();
}
#include <stdio.h> //Nama : Mukhrodi
#include <iostream.h> //NIM : 3420210023
#include <conio.h> //Prodi : Teknik informatika
void main ()
{
int pilih;
char huruf[10];
printf("\tSilahkan-Pilih-Program [1/2]: ");cin>>pilih;
//scanf("%d",&pilih;
/*
There are tvo problems with using scanf() to get a number :
First, validation/error handing is poor.
The second problem is that of leaving characters in the buffer.
Sumber: http://fag.cprogramming.com/cgi-bin/smartfag.cgi?answer=1043372399&id=104384385
*/
if (pilih == 1)
{
clrscr();
puts("\t{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}");
puts("\tContoh-Program-Strlen");
puts("\t{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}");
cout<<endl;
cout<<"\tMasukkan-Sembarang-Kata = ";gets (huruf);
cout<<"\tPanjang-Kata-Yang-Diinputkan = "<<strlen(huruf);
getch();
}
else if (pilih == 2)
{
clrscr();
puts("\t[][][][][][][][][][][][][][][][][][]");
puts("\t\tContoh-Program-Strcmp");
puts("\t[][][][][][][][][][][][][][][][][][]");
char a1[] = "S";
char a2[] = "s";
char b1[] = "S";
cout<<endl;
cout<<"\tHasil Perbandingan "<<a1<<" dan "<<a2<<"->";
cout<<strcmp(a1,a2)<<endl;
cout<<"\tHasil Perbandingan "<<a2<<" dan "<<a1<<"->";
cout<<strcmp(a2,a1)<<endl;
cout<<"\tHasil Perbandingan "<<a1<<" dan "<<b1<<"->";
cout<<strcmp(a1,b1) <<endl;
getch();
}
else
{
printf("\tMaaf pilihan anda salah..");
getch();
}
}
#include <stdio.h> //Nama : Mukhrodi
#include <iostream.h> //NIM : 3420210023
#include <conio.h> //Prodi : Teknik Informatika
void main ()
{
char gol,jab[25];
long gapok;
cout<<endl<<"\tMy-Position"<<endl
<<"\t# # # # # # # # # # # # # # # #"<<endl;
cout<<"\tMasukan Golongan [1/2/3]: ";cin>>gol;
if(gol=='1')
{
strcpy(jab,"CEO");
gapok=3500000;
}
else if(gol=='2')
{
strcpy(jab,"CEO's Wife");
gapok=600000;
}
else if(gol=='3')
{
strcpy(jab,"CEO's Kids");
gapok=4000000;
}
else
{
printf("Golongan %c tidak terdaftar.\n",gol);
strcpy(jab,"None");
gapok=0;
}
cout<<"\tJabatan = "<<jab<<endl;
cout<<"\tGaji Pokok = "<<gapok<<endl;
getch();
}
#include <stdio.h> //Nama : Mukhrodi
#include <iostream.h> //NIM : 3420210023
#include <conio.h> //Prodi : Teknik informatika
void main ()
{
char kode,ukuran,merk[17]="None";
long harga=0;
cout<<"\tKode Baju [1/2] : ";cin>>kode;
cout<<"\tUkuran [XL/M] : ";cin>>ukuran;
if (kode=='1')
{
strcpy(merk, "A.N");
if (ukuran=='XL' || ukuran == 'xl') {harga=300000;} else {harga=250000;}
if (ukuran=='M' || ukuran == 'm') {harga=200000;} else {harga=150000;}
}
else if (kode=='2')
{
strcpy(merk,"Bjor");
//Bentuk penulisan if versi singkat
if (ukuran=='M' || ukuran == 'm') harga=1100000; else harga=1000000;
if (ukuran=='XL' || ukuran == 'xl') harga=1500000; else harga=1300000;
}
else
{
cout<<"\tSalah Kode Baju"<<endl;
}
cout<<"\tMerk Baju : "<<merk<<endl;
cout<<"\tHarga Baju : "<<harga<<endl;
getch();
}
Sekian Terimakasih
Wassalamu'alaikum

.png)
.png)
.png)
.png)
.png)
.png)
.png)
.png)
.png)


Komentar
Posting Komentar