11.Array 2
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
main(){
int x[5];
cout<<"input nilai siswa ke-1= ";
cin>>x[0];
cout<<"input nilai siswa ke-2= ";
cin>>x[1];
cout<<"input nilai siswa ke-3= ";
cin>>x[2];
cout<<"input nilai siswa ke-4= ";
cin>>x[3];
cout<<"input nilai siswa ke-5= ";
cin>>x[4];
clrscr();
cout<<"nilai siswa ke-1= "<<x[0]<<endl;
cout<<"nilai siswa ke-2= "<<x[1]<<endl;
cout<<"nilai siswa ke-3= "<<x[2]<<endl;
cout<<"nilai siswa ke-4= "<<x[3]<<endl;
cout<<"nilai siswa ke-5= "<<x[4]<<endl;
getch();
}
12.Array and Looping1
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
main(){
int x[10];
int i=0;
for(i=0;i<=9;i++){
cout<<"input nilai siswa ke-"<<i+1<<"=";
cin>>x[i];
}
clrscr();
for(i=0;i<=9;i++){
cout<<"nilai siswa ke-"<<i+1<<"=";
cout<<x[i]<<endl;
}
getch();
}
13. Array and Looping2
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
main(){
//tampilkan judul
cout<<"--------------------------------------------------------------------------------"<<endl;
cout<<"\t\t\t\tProgram Nilai Siswa"<<endl;
cout<<"--------------------------------------------------------------------------------"<<endl;
int x[10];
int i=0;
char nama[10][25];
int y;
for(i=0;i<=4;i++){
cout<<"input nama siswa ke-"<<i+1<<"=\t";
cin>>nama[i];
y=strcmp(nama[i],"suud");
if(y==0){
break;
}
cout<<"input nilai siswa ke-"<<i+1<<"=\t";
cin>>x[i];
}clrscr();
//hasil
cout<<"--------------------------------------------------------------------------------"<<endl;
cout<<"\t\t\t\tHasil Nilai Siswa"<<endl;
cout<<"--------------------------------------------------------------------------------"<<endl;
cout<<"-------------------------------------------------"<<endl;
cout<<"|\tNama\t|\tNilai\t|\tGrade\t|"<<endl;
cout<<"-------------------------------------------------"<<endl;
for(i=0;i<=4;i++){
if(x[i]>=80){
cout<<"|\t"<<nama[i]<<"\t|\t"<<x[i]<<"\t|\t"<<"A"<<"\t|"<<endl;
}else if(x[i]>=60){
cout<<"|\t"<<nama[i]<<"\t|\t"<<x[i]<<"\t|\t"<<"B"<<"\t|"<<endl;
}else if(x[i]>=40){
cout<<"|\t"<<nama[i]<<"\t|\t"<<x[i]<<"\t|\t"<<"C"<<"\t|"<<endl;
}else if(x[i]>=20){
cout<<"|\t"<<nama[i]<<"\t|\t"<<x[i]<<"\t|\t"<<"D"<<"\t|"<<endl;
}else{
cout<<"|\t"<<nama[i]<<"\t|\t"<<x[i]<<"\t|\t"<<"E"<<"\t|"<<endl;
}
}
cout<<"-------------------------------------------------"<<endl;
getch();
}
14.Penjualan 1
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
main(){
char kode[3];
char uk[2];
cout<<"--------------------------------------------------------------------------------"<<endl;
cout<<"\t\t\t\tDAFTAR HARGA BARANG"<<endl;
cout<<"--------------------------------------------------------------------------------"<<endl;
cout<<"=================================================================="<<endl;
cout<<"| | | UKURAN |"<<endl;
cout<<"| KODE | NAMA BARANG |---------------------------------------|"<<endl;
cout<<"| | | KECIL(S) | SEDANG(M) | Besar(L) |"<<endl;
cout<<"|----------------------------------------------------------------|"<<endl;
cout<<"| A1 | Sampo | 11.000 | 17.000 | 25.000 |"<<endl;
cout<<"| A2 | Sabun | 1.000 | 1.500 | 2.000 |"<<endl;
cout<<"| A3 | Pasta Gigi | 5.000 | 8.000 | 12.000 |"<<endl;
cout<<"=================================================================="<<endl;
cout<<"kode = ";
cin>>kode;
cout<<"ukuran = ";
cin>>uk;
if(strcmp(strupr(kode),"A1")==0){
cout<<"nama barang = sampo"<<endl;
if(strcmp(strupr(uk),"S")==0){
cout<<"Harga barang = 11.000";
}else if(strcmp(strupr(uk),"M")==0){
cout<<"Harga barang = 17.000";
}else{
cout<<"Harga barang = 25.000";
}
}else if(strcmp(strupr(kode),"A2")==0){
cout<<"nama barang = Sabun"<<endl;
if(strcmp(strupr(uk),"S")==0){
cout<<"Harga barang = 1.000";
}else if(strcmp(strupr(uk),"M")==0){
cout<<"Harga barang = 1.500";
}else{
cout<<"Harga barang = 2.000";
}
}else{
cout<<"nama barang = Pasta Gigi"<<endl;
if(strcmp(strupr(uk),"S")==0){
cout<<"Harga barang = 5.000";
}else if(strcmp(strupr(uk),"M")==0){
cout<<"Harga barang = 8.000";
}else{
cout<<"Harga barang = 12.000";
}
}
getch();
}
15.Gaji Karyawan
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
main(){
int nip[10];
char nama[10][20];
int gol[10];
int i,x;
cout<<"-----------------------------------------\n";
for(i=0;i<=10;i++){
cout<<"| Masukkan NIP Karyawan ke-"<<i+1<<"\t\t| ";
cin>>nip[i];
cout<<"| Masukkan Nama Karyawan ke-"<<i+1<<"\t\t| ";
cin>>nama[i];
if(strcmp(strupr(nama[i]),"SELESAI")==0){
break;
}
cout<<"| Masukkan Golongan Karyawan ke-"<<i+1<<"\t| ";
cin>>gol[i];
}
cout<<"-----------------------------------------\n\n";
//hasil
cout<<"-----------------------------------------------------------------\n";
cout<<"|\tNama Karyawan\t|\tGol\t|\tUpah Per Jam\t|\n";
cout<<"|---------------------------------------------------------------|\n";
for(x=0;x<=i-1;x++){
cout<<"|\t"<<nama[x]<<"\t\t|\t"<<gol[x]<<"\t|\t";
if(gol[x]==1){
cout<<"15.000\t\t|\n";
}else if(gol[x]==2){
cout<<"25.000\t\t|\n";
}else{
cout<<"27.000\t\t|\n";
}
}
cout<<"-----------------------------------------------------------------\n";
getch();
}
16.Gaji Karyawan 2
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
main(){
int jkar,i,m,n,y,z,j;
int max=0;
int min=0;
float jumlah=0;
float banyak=0;
float rata;
int janak[20];
char nama[20][25];
char gol[20][2];
int gapok[20];
long gaji[20];
cout<<"Input Jumlah Karyawan = ";
cin>>jkar;
for(i=0;i<=jkar-1;i++){
cout<<"Input Nama ke-"<<i+1<<" = ";
cin>>nama[i];
cout<<"Input Jumlah Anak "<<nama[i]<<" = ";
cin>>janak[i];
cout<<"Input Golongan "<<nama[i]<<" = ";
cin>>gol[i];
if(strcmp(strupr(gol[i]),"A")==0){
gapok[i]=1000;
}else if(strcmp(strupr(gol[i]),"B")==0){
gapok[i]=1500;
}else{
gapok[i]=2000;
}
if(janak[i]>=3){
gaji[i]=150+gapok[i];
}else{
gaji[i]=50*janak[i]+gapok[i];
}
}
for(i=0;i<=jkar-1;i++){
if(max<=gaji[i]){
max=gaji[i];
n=i;
}
}
for(j=0;j<=jkar-1;j++){
min=gaji[0];
if(min>=gaji[j]){
min=gaji[j];
z=j;
}
jumlah=jumlah+gaji[j];
banyak=banyak+1;
rata=jumlah/banyak;
}
clrscr();
cout<<"Jumlah Karyawan = "<<jkar<<endl;
cout<<"---------------------------------------------------------\n";
cout<<"| NAMA\t\t| JML ANAK\t| GOL\t| GAJI TOTAL\t|\n";
cout<<"---------------------------------------------------------\n";
for(i=0;i<=jkar-1;i++){
cout<<"| "<<nama[i]<<"\t\t| "<<janak[i]<<"\t\t| "<<gol[i]<<"\t| "<<gaji[i]<<"\t\t|\n";
}
cout<<"---------------------------------------------------------\n";
cout<<"Gaji Tertinggi : "<<max<<endl;
cout<<"Gaji Terendah : "<<min<<endl;
cout<<"Karyawan dgn Gaji Tertinggi : "<<nama[n]<<endl;
cout<<"Karyawan dgn Gaji Terendah : "<<nama[z]<<endl;
cout<<"Gaji Total = "<<jumlah<<endl;
cout<<"Rata - Rata = "<<rata;
getch();
}
17.Gaji Karyawan 3
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
main(){
char nama[20][25];
int kar;
int anak[20];
int i;
int gapok=1000;
int total[20];
int tun[20];
cout<<"Jumlah Karyawan = ";
cin>>kar;
for(i=0;i<=kar-1;i++){
cout<<"Nama Karyawan ke-"<<i+1<<" = ";
cin>>nama[i];
cout<<"Jumlah Anak "<<nama[i]<<" = ";
cin>>anak[i];
if(anak[i]==1){
tun[i]=50;
}else if(anak[i]==2){
tun[i]=100;
}else{
tun[i]=150;
}
total[i]=tun[i]+gapok;
}
clrscr();
cout<<"Jumlah Karyawan = "<<kar<<endl;
cout<<"-------------------------------------------------\n";
cout<<"Nama\t\t| Jml Anak\t| Gaji Total\t|\n";
cout<<"-------------------------------------------------\n";
for(i=0;i<=kar-1;i++){
cout<<nama[i]<<"\t\t| "<<anak[i]<<"\t\t|";
cout<<total[i]<<"\t\t|"<<endl;
}
cout<<"-------------------------------------------------\n";
getch();
}
18.Gaji Karyawan 4
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
main(){
int i,j,x;
float rata;
float total=0;
char nama[20][25];
int nilai[20];
int max=0;
float jumlah=0;
for(i=0;i<=20;i++){
cout<<"Input Nama Siswa ke-"<<i+1<<"= ";
cin>>nama[i];
if(strcmp(strupr(nama[i]),"SELESAI")==0){
break;
}
cout<<"Input Nilai Siswa ke-"<<i+1<<"= ";
cin>>nilai[i];
}
clrscr();
for(j=0;j<=i-1;j++){
if(max<=nilai[j]){
max=nilai[j];
x=j;
}
total=total+nilai[j];
jumlah=jumlah+1;
}
rata=total/jumlah;
cout<<"-------------------------\n";
cout<<"| Nama Siswa\t| Nilai\t|\n";
cout<<"-------------------------\n";
for(int j=0;j<=i-1;j++){
cout<<"| "<<nama[j]<<"\t\t| "<<nilai[j]<<"\t|\n";
}
cout<<"-------------------------\n";
cout<<"Nilai Rata - Rata = "<<rata<<endl;
cout<<"Nilai Tertinggi = "<<max<<endl;
cout<<"Nama Siswa dgn Nilai Tertinggi = "<<nama[x]<<endl;
cout<<"jumlah siswa = "<<jumlah<<endl;
cout<<"-------------------------\n";
getch();
}
0 komentar:
Posting Komentar