C++ please ELET 2300 Programming Assignment # 1 Spring 2018 Due: 3/21 Before 11:
ID: 3734265 • Letter: C
Question
C++ please
ELET 2300 Programming Assignment # 1 Spring 2018 Due: 3/21 Before 11:50 PM Write a program that operates a currency conversion between US Dollars (USD) and EURO (EUR). Immediately after execution, the program asks the user to select which conversion is desired: Options: : USD-> EUR 2: EUR->USD Please select an option: After selection, the program asks the user to insert the conversion factor from EUR to USD (e.g. 1 EUR-1.4 USD). Finally, the program converts and displays (in a tabular form) the first ten amounts (1-10 USD or 1-10 EUR) into the destination currency, using the conversion factor provided by the user. Options: 1: USD-> EUR 2: EUR- >USD Please select an option: 2 Please insert the conversion factor (EUR->USD): 1.4Explanation / Answer
#include <iostream>
using namespace std;
int main() {
int n;
double factor;
cout<<"Options: 1. USD->EUR 2. EUR->USD Please select an option:"<<endl;
cin >> n;
if(n == 1) {
cout<<"Please insert the conversion factor(USD->EUR): "<<endl;
cin >> factor;
cout<<"USD EUR"<<endl;
cout<<"-----------------------------------"<<endl;
for(int i=1;i<=10;i++) {
cout<<i<<" "<<i/factor<<endl;
}
} else {
cout<<"Please insert the conversion factor(EUR->USD): "<<endl;
cin >> factor;
cout<<"EUR USD"<<endl;
cout<<"-----------------------------------"<<endl;
for(int i=1;i<=10;i++) {
cout<<i<<" "<<i*factor<<endl;
}
}
return 0;
}
Output:
Options:
1. USD->EUR
2. EUR->USD
Please select an option:
Please insert the conversion factor(EUR->USD):
EUR USD
-----------------------------------
1 1.4
2 2.8
3 4.2
4 5.6
5 7
6 8.4
7 9.8
8 11.2
9 12.6
10 14
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.