Upcoming SlideShare
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

# Saving this for later?

### Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Standard text messaging rates apply

# Contoh uas soal praktek

374
views

Published on

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total Views
374
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
6
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Transcript

• 1. Contoh UAS Soal Praktek C++ #include <stdio> #include <iostream> #include <conio> #include <iomanip> garis(){ puts(“‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐n”); } header(){ puts(“Program input NilaiMahasiswa n” “UjianAkhir Semester n” “2012‐2013 n”); } intn_akhir(intabsen, inttugas, intuts, intuas){ intna=(0.1*absen)+(0.2*tugas)+(0.3*uts)+(0.4*uas); returnna; } char grade(intna){ if(na>85 &&na<=100) return ‘A’; if(na>70 &&na<=85) return ‘B’; if(na>=60 &&na<=70) return ‘C’; if(na>30 &&na<=59) return ‘D’; if(na>0 &&na<=30) return ‘E’; } main(){ struct{ intnim; charnama[20]; intnabsen, ntugas, nuts, nuas; }datamhs[100]; charmatkul[20]; intjmhs; float nrata2=0; header(); garis(); cout<<”input Mata Kuliah : “; gets(matkul); cout<<”input JumlahMhs : “; cin>>jmhs; garis(); for(inti=1;i<=jmhs;i++){ cout<<”Data ke‐”<<i<<endl; cout<<”Input Nim :”; cin>>datamhs[i].nim; cout<<”Input Nama :”; gets(datamhs[i].nama); cout<<”NilaiAbsen :”; cin>>datamhs[i].nabsen; cout<<”NilaiTugas :”; cin>>datamhs[i].ntugas; cout<<”NilaiUts :”; cin>>datamhs[i].nuts; cout<<”NilaiUas :”; cin>>datamhs[i].nuas; int nilai_akhir=n_akhir(datamhs[i].nabsen,datamhs[i].ntugas,datamhs[i].nuts,datamhs[i].nua s); cout<<”NilaiAkhir :”<<nilai_akhir<<endl<<endl; } clrscr(); header(); garis(); cout<<”Mata kuliah :”<<matkul<<endl; garis(); cout<<”No. NIM NamaMhsNilaiAkhr Grade n”; garis(); for(inti=1;i<=jmhs;i++){
• 2. cout<<setiosflags(ios::left)<<setw(4)<<i; cout<<setiosflags(ios::left)<<setw(10)<<datamhs[i].nim; cout<<setiosflags(ios::left)<<setw(15)<<datamhs[i].nama; int nilai_akhir=n_akhir(datamhs[i].nabsen,datamhs[i].ntugas,datamhs[i].nuts,datamhs[i].nua s); cout<<setiosflags(ios::right)<<setw(10)<<nilai_akhir; cout<<setiosflags(ios::right)<<setw(4)<<grade(nilai_akhir)<<endl; nrata2+=nilai_akhir; } garis(); cout<<”Nilai rata‐rata mahasiswaadalah “<<(nrata2/jmhs)<<endl; getch(); } #include<iostream.h> #include<iomanip.h> #include<stdio.h> #include<conio.h> main() { struct { char jenis[10]; int kode; float lama,harga,pajak,total; }penyewaan[6]; int i,j; char nama[25],tgl[10]; float totalbiaya=0,diskon=0,totalbayar=0; clrscr(); cout<<"Jumlah sewa = ";cin>>j; cout<<"Nama Sewa = ";cin>>nama; cout<<"Tanggal Sewa = ";cin>>tgl; clrscr(); for(i=1;i<=j;i++) { cout<<"Data Penyewa Ke - "<<i<<endl; cout<<"Kode Mobil = ";cin>>penyewaan[i].kode; cout<<"Jenis Mobil= ";cin>>penyewaan[i].jenis; cout<<"Lama Sewa = ";cin>>penyewaan[i].lama; cout<<"Harga Sewa = ";cin>>penyewaan[i].harga; cout<<endl; if(penyewaan[i].kode=='1') penyewaan[i].pajak=150000; else penyewaan[i].pajak=100000; penyewaan[i].total=(penyewaan[i].lama*penyewaan[i].harga)+penyewaan[i].pajak; totalbiaya+=penyewaan[i].total; diskon=0.1*totalbiaya; totalbayar=totalbiaya-diskon; } clrscr(); cout<<" DAFTAR PENYEWA MOBIL"<<endl; cout<<" PT. SAFETY TRANSPORTATION"<<endl; cout<<"=============================================================="<<endl; cout<<"No Kode Jenis Lama Harga Pajak Total"<<endl;
• 3. cout<<" Mobil Mobil Sewa Sewa"<<endl; cout<<"=============================================================="<<endl; for(i=1;i<=j;i++) { printf("%d %8s %8s %8.0f %8.0f %8.0f %8.0f", i,penyewaan[i].kode,penyewaan[i].jenis,penyewaan[i].lama, penyewaan[i].harga,penyewaan[i].pajak,penyewaan[i].total); cout<<endl; } cout<<"=============================================================="<<endl; printf("Total Biaya Sewa= Rp. %0.0f",totalbiaya);cout<<endl; printf("Diskon= Rp. %0.0f",diskon);cout<<endl; printf("Total Pembayaran= Rp. %0.0f",totalbayar);cout<<endl;} #include<conio.h> #include<stdio.h> #include<iostream.h> #include<iomanip.h> main() { int i; char nama[5][20]; float nilai1[5]; float nilai2[5]; float hasil[5]; clrscr(); for(i=1;i<=2;i++) { cout<<"Data ke- "<<i<<endl; cout<<"Nama Siswa : ";gets(nama[i]); cout<<"Nilai Teori : ";cin>>nilai1[i]; cout<<"Nilai Praktek : ";cin>>nilai2[i]; hasil[i]=(nilai1[i]*0.40)+(nilai2[i]*0.60); cout<<endl; } clrscr(); cout<<endl<<endl; cout<<"------------------------------------"<<endl; cout<<"No. Nama Siswa Nilai Nilai Hasil "<<endl; cout<<" Teori Praktek Ujian "<<endl; cout<<"------------------------------------"<<endl; for(i=1;i<=2;i++) { cout<<setiosflags(ios::left)<<setw(4)<<i; cout<<setiosflags(ios::left)<<setw(10)<<nama[i]; cout<<setprecision(2)<<" "<<nilai1[i]; cout<<setprecision(2)<<" "<<nilai2[i]; cout<<setprecision(2)<<" "<<hasil[i]<<endl; } getch(); }
• 4. Soal 1, ARRAY DATA MAHASISWA #include<stdio.h> #include"conio.h" #include"iostream.h" #include"iomanip.h" main() { int a,n; char nama[5][20],nim[5][8]; char kelas[5][6],grade[5],ket[5][6]; int uts[5],uas[5],rata[5]; clrscr(); cout<<"Jumlah Data ? ";cin>>n; for(a=1;a<=n;a++) { clrscr(); cout<<"Data Ke: "<<a<<endl; cout<<"Nama: ";gets(nama[a]); cout<<"Kelas: ";cin>>kelas[a]; cout<<"Nim: ";cin>>nim[a]; cout<<"Nilai UTS: ";cin>>uts[a]; cout<<"Nilai UAS: ";cin>>uas[a]; rata[a]=(uts[a]+uas[a])/2; if(rata[a]>=80) { grade[a]='A'; strcpy(ket[a],"LULUS"); } else if(rata[a]>=70) { grade[a]='B'; strcpy(ket[a],"LULUS"); } else if(rata[a]>=60) { grade[a]='C'; strcpy(ket[a],"LULUS"); } else if(rata[a]>=50) { grade[a]='D'; strcpy(ket[a],"GAGAL"); } else { grade[a]='E'; strcpy(ket[a],"GAGAL"); } cout<<endl; } clrscr(); cout<<"Daftar Nilai Mahasiswa"<<endl; cout<<"----------------------------------------------------------------------"<<endl; cout<<"No Nama Nim Kelas Nilai Nilai Rata Grade Keterangan"<<endl; cout<<" UTS UAS Rata"<<endl; cout<<"----------------------------------------------------------------------"<<endl; for(a=1;a<=n;a++) { cout<<setiosflags(ios::left)<<setw(3)<<a; cout<<setiosflags(ios::left)<<setw(10)<<nama[a]; cout<<setiosflags(ios::left)<<setw(13)<<nim[a]; cout<<setiosflags(ios::left)<<setw(11)<<kelas[a];
• 5. cout<<setiosflags(ios::left)<<setw(6)<<uts[a]; cout<<setiosflags(ios::left)<<setw(6)<<uas[a]; cout<<setiosflags(ios::left)<<setw(5)<<rata[a]; cout<<setiosflags(ios::left)<<setw(6)<<grade[a]; cout<<setiosflags(ios::left)<<setw(10)<<ket[a]<<endl; } cout<<"----------------------------------------------------------------------"<<endl; getch(); }