//Nama = Tomas Sasra Bahu
//NIM = 3420210028
//Prodi = Teknik Informatika
//Deklarasi Variable
int absen,tugas,uts,uas;
float total;
puts("Program Menghitung Nilai Mahasiswa");
puts("===============================");
printf("Masukan nilai Absen : ");cin>>absen;
cout<<("Masukan nilai Tugas : ");cin>>tugas;
printf("Masukan nilai UTS : ");cin>>uts;
cout<<("Masukan nilai UAS : ");cin>>uas;
//Proses Perhitungan
total = (absen*0.1)+(tugas*0.2)+(uts*0.3)+(uas*0.4);
puts("===========================");
cout<<"Total adalah: "<<total<<" (bentuk tidak terformat)\n";
printf("Total adalah: %.2f (bentuk yang terformat)\n",total);
puts("===========================");
//Kondisi
if (total >=75 )
{ cout<<"Selamat anda lulus."; }
else
{ cout<<"Maaf anda tidak lulus."; }
getch();
}
Tugas 2
Tugas 2
Berikut perintah yang harus dijalankan :
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <iostream.h>
//Nama = Tomas Sasra Bahu
//NIM = 3420210028
//Prodi = Teknik Informatika
void main()
{
int pilih;
char huruf[16];
printf("Silahkan pilih program [1/2]: ");cin>>pilih;
//scanf("%d",&pilih);
/*
There are two problems with using scanf() to get a number:
First, Validation/error handling is poor.
The second problems is that of leaving characters in the buffer.
Sumber: http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?anever-1043372399sid=1043284385
*/
if (pilih == 1)
{
clrscr();
puts("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
puts("\tContoh Program Strlen");
puts("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
cout<<"Masukan Sembarang Kata = ";gets(huruf);
cout<<"Panjang Kata Yang Diinputkan = "<<strlen(huruf);
getch();
}
else if (pilih == 2)
{
clrscr();
puts("#####################################");
puts("\tContoh Program Strcmp");
puts("#####################################");
char a1[ ] = "S";
char a2[ ] = "s";
char b1[ ] = "S";
cout<<"Hasil Perbandingan "<<a1<<" dan "<<a2<<"->";
cout<<strcmp(a1,a2)<<endl;
cout<<"Hasil Perbandingan "<<a2<<" dan "<<a1<<"->";
cout<<strcmp(a2,a1)<<endl;
cout<<"Hasil Perbandingan "<<a1<<" dan "<<b1<<"->";
cout<<strcmp(a1,b1)<<endl;
getch();
}
else
{
printf("Maaf pilihan anda anda salah..");
getch();
}
}
Tugas 3
Tugas 3
Berikut perintah yang harus dijalankan :
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
//Nama = Tomas Sasra Bahu
//NIM = 3420210028
//Prodi = Teknik Informatika
void main()
{
char gol,jab[25];
long gapok;
cout<<endl<<"Data Pegawai Restaurant"<<endl
<<"+++++++++++++++++++++++++++++++++"<<endl;
cout<<"Masukan Golongan [1/2/3]: ";cin>>gol;
if(gol=='1')
{
strcpy(jab,"Koki");
gapok= 9000000;
}
else if(gol=='2')
{
strcpy(jab,"Kasir");
gapok= 3500000;
}
else if(gol=='3')
{
strcpy(jab,"Pelayan");
gapok= 3000000;
}
else
{
printf("Golongan %c tidak terdaftar.\n",gol);
strcpy(jab,"None");
gapok=0;
}
cout<<"Jabatan = "<<jab<<endl;
cout<<"Gaji Pokok = "<<gapok<<endl;
getch();
}
Tugas 4
Tugas 4
Berikut perintah yang harus dijalankan :
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
//Nama = Tomas Sasra Bahu
//NIM = 3420210028
//Prodi = Teknik Informatika
void main()
{
char kode,ukuran,merk[15]="None";
long harga=0;
cout<<"Kode Baju [1/2] : ";cin>>kode;
cout<<"Ukuran [S/M/L] : ";cin>>ukuran;
if(kode=='1')
{
strcpy(merk,"Kuy lah");
if (ukuran=='S' || ukuran =='s') { harga=90000; } else { harga=100000; }
if (ukuran=='M' || ukuran =='m') { harga=95000; } else { harga=105000; }
if (ukuran=='L' || ukuran =='l') { harga=100000; } else { harga=110000; }
}
else if(kode=='2')
{
strcpy(merk,"Unikloh");
//Bentuk penulisan if versi singkat
if (ukuran=='S' || ukuran =='s') { harga=115000; } else { harga=150000; }
if (ukuran=='M' || ukuran =='m') { harga=155000; } else { harga=170000; }
if (ukuran=='L' || ukuran =='l') { harga=175000; } else { harga=200000; }
}
else
{
cout<<"Salah Kode Baju"<<endl;
}
cout<<"Merk Baju : "<<merk<<endl;
cout<<"Harga Baju : "<<harga<<endl;
getch();
}
Cukup Sekian Dan Terima Kasih
Semoga Bermanfaat
Tidak ada komentar:
Posting Komentar