Informatics - Currency Change Calc Version 1 (Week 16)
OMG It's holiday time! Happy holiday everyone!
Anyway, are you planning to go somewhere on this holiday? Is there any of you who wants to go to outside of the country but still confused about the budget there because you don't know how to calculate currency change? No need to worry! I'm here to help you.
So the base of the code will be the same as the length converter which we're going to use functions and switch statement. In this program I will convert Rupiahs to Won and otherwise. So, the first thing you need to find is the currency change. You can find it on google! So here 1 Rupiah is equal to 0.089 Won and 1 Won is equal to 11.26 Rupiahs.
Here's the code of the program!
//program CurrencyChangeCalc.cpp
#include <iostream>
using namespace std;
double rupiah, won;
void rupiah2won(){
cout << "Enter money in rupiah:";
cin >> rupiah;
won = rupiah*0.089;
cout << rupiah << " rupiah is equal to " << won << " won." << endl;
}
void won2rupiah(){
cout << "Enter money in won:";
cin >> won;
rupiah = won*11.26;
cout << won << " won is equal to " << rupiah << " rupiah." << endl;
}
int main () {
int choice;
cout << "Choose procedure type: \n";
cout << "1. Convert rupiah to won \n";
cout << "2. Convert won to rupiah \n";
cout << "Choose between 1 or 2! \n";
cout << "Enter your choice: my choice is ";
cin >> choice;
switch (choice) {
case 1:
rupiah2won();
break;
case 2:
won2rupiah();
break;
default:
cout << "!!!YOU PUT THE WRONG INPUT!!!" << endl;
cout << "-------!!!ERROR!!!--------" << endl;
}
}
Here's the output of the program!
Here, I choose 2 which means I want to convert won to rupiah. Then I entered 100 Won to convert. It then calculates 100 multiples by 11.26 and the result is 100 won is equal to 1126 Rupiah. So, that's the code of the Currency Change Calc. Enjoy your holiday!
.png)
Komentar
Posting Komentar