Task 1: Create an Array that holds a 20 random integers between 1-50. Create an
ID: 3799431 • Letter: T
Question
Task 1:
Create an Array that holds a 20 random integers between 1-50.
Create an iterator that will return the memory address and value for each integer present in the Array.
Task 2:
Update Assignment 1 Task 2.
Pass the values by reference to complete the programming tasks.
Using multiple functions and receiving user input.
In your main function use a switch case to create a menu for the user.
Create a program that converts user input in Dollars to Euro, Yen, or Peso.
Prompt the user to enter $ amount.
If user input is less than or equal to zero prompt the user and stop the program.
Create 4 Functions:
1) Converts and outputs conversion in Yen
2) Converts and outputs conversion in Euro
3) Converts and outputs conversion in Peso
4) Converts and outputs all 3 currencies.
Update the program to accept user input for dollar amount to be converted.
Attach Snipping photos of all 4 methods being executed.
Use C++ language please
!!
Explanation / Answer
Task1
c++ code:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int arr[20];
for (int i = 0; i < 20; ++i)
{
arr[i] = rand()%50 + 1;
}
for (int i = 0; i < 20; ++i)
{
cout << &arr[i] << " " << arr[i] << endl;
}
return 0;
}
Task 2:
#include <bits/stdc++.h>
using namespace std;
int main()
{
float d;
int c;
cout << "Enter Amount in Dollers" << endl;
cin >> d;
cout << "Enter 1 to convert into Euro" << endl;
cout << "Enter 2 to convert into Yen" << endl;
cout << "Enter 3 to convert into Peso" << endl;
cout << "Enter 4 to Convert and output all 3 currencies" << endl;
cin >> c;
if(c == 1)
{
cout << d << " Dollers = " << d*0.94 << " Euro ";
}
else if(c == 2)
{
cout << d << " Dollers = " << d*112.81 << " Yen ";
}
else if(c == 3)
{
cout << d << " Dollers = " << d*19.93 << " Peso ";
}
else if(c == 4)
{
cout << d << " Dollers = " << d*0.94 << " Euro ";
cout << d << " Dollers = " << d*112.81 << " Yen ";
cout << d << " Dollers = " << d*19.93 << " Peso ";
}
return 0;
}
Sample Output:
Enter Amount in Dollers
5
Enter 1 to convert into Euro
Enter 2 to convert into Yen
Enter 3 to convert into Peso
Enter 4 to Convert and output all 3 currencies
1
5 Dollers = 4.7 Euro
akash@akash-SVE15116ENB:~/Desktop/chegg/dollar to euros$ ./a.out
Enter Amount in Dollers
5
Enter 1 to convert into Euro
Enter 2 to convert into Yen
Enter 3 to convert into Peso
Enter 4 to Convert and output all 3 currencies
2
5 Dollers = 564.05 Yen
akash@akash-SVE15116ENB:~/Desktop/chegg/dollar to euros$ ./a.out
Enter Amount in Dollers
5
Enter 1 to convert into Euro
Enter 2 to convert into Yen
Enter 3 to convert into Peso
Enter 4 to Convert and output all 3 currencies
3
5 Dollers = 99.65 Peso
akash@akash-SVE15116ENB:~/Desktop/chegg/dollar to euros$ ./a.out
Enter Amount in Dollers
5
Enter 1 to convert into Euro
Enter 2 to convert into Yen
Enter 3 to convert into Peso
Enter 4 to Convert and output all 3 currencies
4
5 Dollers = 4.7 Euro
5 Dollers = 564.05 Yen
5 Dollers = 99.65 Peso
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.