tugas c++

#include <iostream.h>
#include <stdio.h>
#include <conio.h>
potong (long disc, long belanja=0, long bayar=0)
{
cout<<” Pembelian Barang = “;cin>>belanja;
if(belanja>5000000)
{disc=(belanja*35)/100;}
else if(belanja>=1000000 && belanja<=5000000) 
{disc=belanja*0.2;}
else if(belanja<1000000)
{disc=0;}
cout<<” Discount = Rp. “<<disc<<endl;
bayar=belanja-disc;
cout<<” Jumlah Yang Harus Dibayar = “<<bayar<<endl;
}

void main()
{
char lagi;
int disc, belanja, bayar;

mulai:
clrscr();
cout<<” Struk Diskon”<<endl;
cout<<“==============================================”<<endl;
potong (disc, belanja, bayar);
cout<<“==============================================”<<endl;
cout<<” Input Data Lagi? “;cin>>lagi;
if(lagi==’Y’||lagi==’y’)
goto mulai;
else
goto akhir;

akhir:
getch();
}

HALAMAN BERIKUTNYA

#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <iomanip.h>
main()
{
int a,n;
struct
{
char nama[9][10],*grade[5];
int uts[5],uas[5],akhir[5];
}mhs;

cout<<” Masukan Jumlah Data : “;cin>>n;
for(a=1;a<=n;a++)
{
cout<<endl;
cout<<“Data Ke : “<<a<<endl;
cout<<endl;
cout<<“Nama Mahasiswa : “;cin>>mhs.nama[a];
cout<<“Nilai UTS : “;cin>>mhs.uts[a];
cout<<“Nilai UAS : “;cin>>mhs.uas[a];
mhs.akhir[a]=(mhs.uts[a]*0.4+mhs.uas[a]*0.6);
if(mhs.akhir[a]>=80)
{mhs.grade[a]=”A”;}
else if(mhs.akhir[a]>=70)
{mhs.grade[a]=”B”;}
else if(mhs.akhir[a]>=60)
{mhs.grade[a]=”C”;}
else if(mhs.akhir[a]>=50)
{mhs.grade[a]=”D”;}
else
{mhs.grade[a]=”E”;}
cout<<endl;
}
clrscr();
cout<<“Daftar Nilai Mahasiswa”<<endl;
cout<<“———————————————————————-“<<endl;
//123456789012345678901234567890123456789012345678901234567890
cout<<“No Nama Nilai Nilai Nilai”<<endl;
cout<<” Mahasiswa UTS UAS Akhir Huruf”<<endl;
cout<<“———————————————————————-“<<endl;
//123456789012345678901234567890123456789012345678901234567890
for(a=1;a<=n;a++)
{
cout<<setiosflags(ios::left)<<setw(4)<<a;
cout<<setiosflags(ios::left)<<setw(18)<<mhs.nama[a];
cout<<setiosflags(ios::left)<<setw(6)<<mhs.uts[a];
cout<<setiosflags(ios::left)<<setw(10)<<mhs.uas[a];
cout<<setiosflags(ios::left)<<setw(14)<<mhs.akhir[a];
cout<<setiosflags(ios::left)<<setw(24)<<mhs.grade[a]<<endl;
}
cout<<“———————————————————————-“<<endl;
getch();
}

Tinggalkan komentar

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

Buat situs web atau blog gratis di WordPress.com.

%d blogger menyukai ini: