Calculate the area of a circle, square or circle around the area may need branching to the program, and for now I use a switch case.
Directly to the heart of the matter, I've created this program as simple as possible to avoid mistakes for new programmers to learn,,
This time I give direct his script c + +, so you can simply copy and paste :
#include <iostream.h>
#include <conio.h>
#include <iomanip.h>
main() {
int l,p,r,pil,t;
float Luas,Kel;
const float phi=3.14;
bool jwb;
cek:
cout<<"Pilihan menu :\n";
cout<<"[1] Luas Lingkaran \n";
cout<<"[2] Luas Persegi \n";
cout<<"[3] Keliling Lingkaran \n";
cout<<"Masukkan pilihan anda : ";cin>>pil;
switch (pil){
case 1 :
cout<<"Masukkan jari-jari : ";cin>>r;
Luas=phi*(r*r);
cout<<"\nLuas Lingkaran : "<<Luas<<endl<<endl;
cout<<"Anda ingin mengulang?[1=ya,0=tdk] ";cin>>jwb;
if(jwb==1)
goto cek;
else
cout<<"Terima kasih";
break;
case 2 :
cout<<"Masukkan panjang : ";cin>>p;
cout<<"Masukkan lebar : ";cin>>l;
Luas=p*l;
cout<<"\nLuas Persegi : "<<Luas<<endl<<endl;
cout<<"Anda ingin mengulang?[1=ya,0=tdk] ";cin>>jwb;
if(jwb==1)
goto cek;
else
cout<<"Terima kasih";
break;
case 3 :
cout<<"Masukkan jari-jari : ";cin>>r;
Kel=(phi*r)*2;
cout<<"\nKeliling Lingkaran : "<<Kel<<endl<<endl;
cout<<"Anda ingin mengulang?[1=ya,0=tdk] ";cin>>jwb;
if(jwb==1)
goto cek;
else
cout<<"Terima kasih";
break;
default :
cout<<"Maaf pilihan menu yang anda inputkan tidak terdaftar ";}
getch();}
And when you run the program, the display will come out like this:
You now can select the menu :)
Directly to the heart of the matter, I've created this program as simple as possible to avoid mistakes for new programmers to learn,,
This time I give direct his script c + +, so you can simply copy and paste :
#include <iostream.h>
#include <conio.h>
#include <iomanip.h>
main() {
int l,p,r,pil,t;
float Luas,Kel;
const float phi=3.14;
bool jwb;
cek:
cout<<"Pilihan menu :\n";
cout<<"[1] Luas Lingkaran \n";
cout<<"[2] Luas Persegi \n";
cout<<"[3] Keliling Lingkaran \n";
cout<<"Masukkan pilihan anda : ";cin>>pil;
switch (pil){
case 1 :
cout<<"Masukkan jari-jari : ";cin>>r;
Luas=phi*(r*r);
cout<<"\nLuas Lingkaran : "<<Luas<<endl<<endl;
cout<<"Anda ingin mengulang?[1=ya,0=tdk] ";cin>>jwb;
if(jwb==1)
goto cek;
else
cout<<"Terima kasih";
break;
case 2 :
cout<<"Masukkan panjang : ";cin>>p;
cout<<"Masukkan lebar : ";cin>>l;
Luas=p*l;
cout<<"\nLuas Persegi : "<<Luas<<endl<<endl;
cout<<"Anda ingin mengulang?[1=ya,0=tdk] ";cin>>jwb;
if(jwb==1)
goto cek;
else
cout<<"Terima kasih";
break;
case 3 :
cout<<"Masukkan jari-jari : ";cin>>r;
Kel=(phi*r)*2;
cout<<"\nKeliling Lingkaran : "<<Kel<<endl<<endl;
cout<<"Anda ingin mengulang?[1=ya,0=tdk] ";cin>>jwb;
if(jwb==1)
goto cek;
else
cout<<"Terima kasih";
break;
default :
cout<<"Maaf pilihan menu yang anda inputkan tidak terdaftar ";}
getch();}
And when you run the program, the display will come out like this:
You now can select the menu :)
No comments:
Post a Comment