//calculator sederhana
//created by otaku-it
#include <iostream>
using namespace std;
int main(){
float a,b,hasil;
char arimatika;
cout << "Ini adalah calculator sederhana\n";
cout << "masukkan nilai pertama:";
cin >> a;
cout << "masukkan operator +,-,/,*:";
cin >> arimatika;
cout << "masukkan nilai kedua:";
cin >> b;
cout << "hasilnya adalah:";
if (arimatika == '+'){
hasil = a+b;
cout << a << arimatika << b <<" = "<< hasil << endl;
}
else if(arimatika == '-'){
hasil = a-b;
cout << a << arimatika << b <<" = "<< hasil << endl;
}
else if(arimatika == '/'){
hasil = a/b;
cout << a << arimatika << b <<" = "<< hasil << endl;
}
else if(arimatika == '*'){
hasil = a*b;
cout << a << arimatika << b <<" = "<< hasil << endl;
}
else {
cout << "error\n";
}
return 0;
}
seperti itulah dan jika dijalankan maka akan seperti gambar dibawah ini:
selamat mencoba /('-')\('-')\ Admin@1v3z
No comments:
Post a Comment