List Program:
1. Pembagian
2. Luas Lingkaran
3. Keliling Lingkaran
4. Luas Segitiga
5. Keliling Segitiga
6. Volume Bola
7. Operasi Pangkat (x pangkat n)
8. Operasi Akar (akar dari x)
9. Persamaan Kuadrat a(x*x)+b(x)+c
10. Kasir
11. Konversi Bilangan ke Angka Romawi
Langsung aja gan cek codingnya.... :D
#include
#include
#include
#include
#include
#include
void hitung();
void konversi();
void garis ();
long total (int x, int y);
int ribuan = 0;
int limaratusan = 0;
int ratusan = 0;
int limapuluhan = 0;
int puluhan = 0;
int limaan = 0;
int satuan = 0;
int desimal;
char romawi[30];
void main()
{
const float phi = 3.14;
float a,b,c,d,e,f,n,r,x;
char m;
cout<<"SELAMAT DATANG DI PROGRAM MATEMATIKA"<<endl<<endl;
cout<<"oleh : Firman Oktafian (18123552)"<<endl;
cout<<endl;
cout<<"Press any key to continue";
getch() ;
clrscr();
do
{
clrscr();
cout<<"|======================================|"<<endl;
cout<<"| Nama : Firman Oktafian"<<endl;
cout<<"| Nim : 18123552"<<endl;
cout<<"| Kelas : 12.1L.13"<<endl;
cout<<"|======================================|"<<endl;
cout<<"| PROGRAM FUNGSI MATEMATIKA"<<endl;
cout<<"|======================================|"<<endl;
cout<<"| Menu Pilihan"<<endl;
cout<<"|======================================|"<<endl;
cout<<"| 1. Pembagian"<<endl;
cout<<"| 2. Luas Lingkaran"<<endl;
cout<<"| 3. Keliling Lingkaran"<<endl;
cout<<"| 4. Luas Segitiga"<<endl;
cout<<"| 5. Keliling Segitiga"<<endl;
cout<<"| 6. Volume Bola"<<endl;
cout<<"| 7. Operasi Pangkat (x pangkat n)"<<endl;
cout<<"| 8. Operasi Akar (akar dari x)"<<endl;
cout<<"| 9. Persamaan Kuadrat a(x*x)+b(x)+c"<<endl;
cout<<"| 10. PROGRAM KASIR"<<endl;
cout<<"| 11. PROGRAM KONVERSI KE BIL. ROMAWI"<<endl;
cout<<"|======================================|"<<endl;
cout<<endl;
cout<<"Masukkan Menu Pilihan : ";
cin>>d;
if(d==1)
{
clrscr();
cout<<"Masukan angka 1 : ";
cin>>a;
cout<<"Masukan angka 2 : ";
cin>>b;
c=a/b;
cout<<a<<" / "<<b<<" = "<<c<<endl;
cout<<"Terima Kasih - Firman"<<endl;
cout<<endl;
}
else if(d==2)
{
clrscr();
cout<<"Masukan jari :";
cin>>a;
c=phi*a*a;
cout<<"Luas Lingkaran = "<<phi<<" * "<<a<<" * "<<a<<" = "<<c<<endl;
cout<<"Terima Kasih - Firman"<<endl;
cout<<endl;
}
else if(d==3)
{
clrscr();
cout<<"Masukan jari-jari : ";
cin>>a;
c=2*phi*a;
cout<<"Keliling Lingkaran = "<<2<<" * "<<phi<<" * "<<a<<" = "<<c<<endl;
cout<<"Terima Kasih - Firman"<<endl;
cout<<endl;
}
else if(d==4)
{
clrscr();
cout<<"Masukan Alas : ";
cin>>a;
cout<<"Masukan Tinggi : ";
cin>>b;
c=0.5*a*b;
cout<<"Luas Segitiga = "<<0.5<<" * "<<a<<" * "<<b<<" = "<<c<<endl;
cout<<"Terima Kasih - Firman"<<endl;
cout<<endl;
}
else if(d==5)
{
clrscr();
cout<<"Masukan Alas : ";
cin>>a;
cout<<"Masukan Tinggi : ";
cin>>b;
c=a*b;
cout<<"Keliling Segitiga = "<<a<<" * "<<b<<" = "<<c<<endl;
cout<<"Terima Kasih - Firman"<<endl;
cout<<endl;
}
else if(d==6)
{
clrscr();
cout<<"Masukan jari-jari : ";
cin>>r;
c=1.33333*phi*r*r*r;
cout<<"Volume Bola = "<<"4/3"<<" * "<<phi<<" * "<<r<<" * "<<r<<" * "<<r<<" = "<<c<<endl;
cout<<"Terima Kasih - Firman"<<endl;
cout<<endl;
}
else if(d==7)
{
clrscr();
cout<<"masukkan x : ";cin>>x;
cout<<"masukkan n : ";cin>>n;
a= pow(x,n);
cout<<endl;
cout<<x<<" pangkat "<<n<<" = "<<a<<endl;
cout<<"Terima Kasih - Firman"<<endl;
}
else if(d==8)
{
clrscr();
cout<<"masukkan x : ";cin>>x;
a= sqrt(x);
cout<<endl;
cout<<" akar dari "<<x<<" = "<<a<<endl;
cout<<"Terima Kasih - Firman"<<endl;
}
else if(d==11)
{
clrscr();
{
char lagi;
char kosong[30]="";
do
{
clrscr();
strcpy(romawi,kosong);
hitung();
konversi();
cout<<"Bilangan Romawinya adalah : "<<romawi<<endl;
cout<<"Terima Kasih - Firman"<<endl;
cout<<"ulangi ? : "; cin>>lagi;
lagi=toupper(lagi);
} while((lagi=='Y')||(lagi=='y'));
getch();
}
}
else if(d==9)
{
clrscr();
cout<<"masukkan nilai a : ";cin>>a;
cout<<"masukkan nilai b : ";cin>>b;
cout<<"masukkan nilai c : ";cin>>c;
d=sqrt(b*b-4*a*c);
if(d>=0)
{
e=(-b-d)/(2*a);
f=(-b+d)/(2*a);
cout<<"x1 : "<<e<<endl;
cout<<"x2 : "<<f<<endl<<endl;
}
else
cout<<"akar imajiner"<<endl;
cout<<"Terima Kasih - Firman"<<endl;
}
else if(d==10)
{
clrscr();
cout<<"PROGRAM KASIR FIRMAN(MAKSIMAL 3)"<<endl<<endl;
char nama [25], harga [15], qty [10];
gotoxy (2,2);garis ();
gotoxy (2,3);cout<<"Nama Barang";
gotoxy (25,3);cout<<"Harga";
gotoxy (40,3);cout<<"QTY";
gotoxy (50,3);cout<<"Bayar";
gotoxy (2,4);garis ();
for (int i=1;i<=3;i++)
{
gotoxy(2,4+i);cin.getline(nama, sizeof(nama));
gotoxy(25,4+i);cin.getline(harga, sizeof(harga));
gotoxy(40,4+i);cin.getline(qty, sizeof(qty));
gotoxy(50,4+i);cout<<total(atoi(harga),atoi(qty));
cout<<endl<<endl;
}
}
else
{
cout<<"\n kode salah..!!"<<endl<<endl;
}
cout<<"\nIngin Masuk Menu Lagi(Y/T)?";
cin>>m;
}
while ((m=='y')||(m=='Y'));
getch();
}
void garis()
{
cout<<"=============================================================="<<endl;
}
long total(int x,int y)
{
return (x*y);
}
void hitung()
{
ulang :
cout<<"masukan bilangan desimal (1..3999) : "; cin>>desimal;
if (desimal>3999)
{
cout<<"diluar jangkauan"<<endl;
goto ulang;
}
else
proses:
if (desimal >= 1000)
{
ribuan = desimal / 1000;
desimal = desimal % 1000;
goto proses;
}
else if (desimal >=500)
{
limaratusan = desimal / 500;
desimal = desimal % 500;
goto proses;
}
else if (desimal >= 100)
{
ratusan = desimal / 100;
desimal = desimal % 100;
goto proses;
}
else if (desimal >= 50)
{
limapuluhan = desimal / 50;
desimal = desimal % 50;
goto proses;
}
else if (desimal >= 10 )
{
puluhan = desimal / 10;
desimal = desimal % 10;
goto proses;
}
else if (desimal >=5)
{
limaan = desimal / 5;
desimal = desimal % 5;
goto proses;
}
else
satuan = desimal;
}
void konversi()
{
for(int i=1; i<=ribuan;i++)
strcat(romawi,"M");
if((limaratusan==1)&&(ratusan !=4))
strcat(romawi,"D");
if((limaratusan==0)&&(ratusan==4))
strcat(romawi,"CD");
else
if((limaratusan==1)&&(ratusan==4))
strcat(romawi,"CM");
else
for(int i=1;i<=ratusan;i++)
strcat(romawi,"C");
if((limapuluhan==1)&&(puluhan!=4))
strcat(romawi,"L");
if((limapuluhan==0)&&(puluhan==4))
strcat(romawi,"XL");
else
if((limapuluhan==1)&&(puluhan==4))
strcat(romawi,"XC");
else
for(int i=1;i<=puluhan;i++)
strcat(romawi,"X");
if((limaan==1)&&(satuan!=4))
strcat(romawi,"V");
if((limaan==0)&&(satuan==4))
strcat(romawi,"IV");
else
if((limaan==1)&&(satuan==4))
strcat(romawi,"IX");
else
for(int i=1;i<=satuan;i++)
strcat(romawi,"I");
}
Tidak ada komentar:
Posting Komentar