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;
    }
}

It starts by asking the user to choose a conversion type: press 1 to convert Rupiah to Won or press 2 to convert Won to Rupiah. Depending on the choice, the program calls one of two functions. The rupiah2won() function takes the user's input in Rupiah, multiplies it by 0.089, and displays the equivalent amount in Won. Similarly, the won2rupiah() function takes an amount in Won, multiplies it by 11.26, and shows the result in Rupiah. The program uses a switch statement to execute the correct function based on the user's selection. If the user enters an invalid choice, an error message is displayed to notify them of the mistake.

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!

Komentar

Postingan populer dari blog ini

Informatics - Making a Main C++ Program to Run all the Calculator Program (week 11)

Informatics - Triangles (week 18)

Informatics - Making Minimarket Discount Program in C++ version 1 (Week 12)