C++ 1.Your program will prompt the user for a U.S. Dollar amount and convert the
ID: 3684687 • Letter: C
Question
C++ 1.Your program will prompt the user for a U.S. Dollar amount and convert the U.S Dollar amount to the Chinese Yuan currency. You must use only one pointer. Your program must print the U.S Dollar amount and the Chinese Yuan converted amount. Your program should allow the user to repeat the program using different dollar values until the user decides to quit the program. Call your program Conversion.cpp. Don't forget your algorithm and heading needs to be in the file.
2.Create an array of planets. Populate the array and print the contents of the array using the pointer notation instead of the subscripts. Call your program Planets.cpp. Comment
Explanation / Answer
//the code is for 1st question
#include <iostream>
using namespace std;
int main() {
float usd,curr_yuan;
float *ptr;
ptr=&usd;
while(1)
{
cout <<"enter the amount in U.S Dollars (or) to quit enter 0:";
cin >> usd;
curr_yuan=usd*6.48; // converting US Dollars to chinese yuan
cout << "entered amount in US Dollars is :";
cout << *ptr <<endl; // printing accteped USD
cout <<"the chinese yuan for the given US Dollars is :";
cout << curr_yuan <<endl; // printing converted currency
return 1;
}
return 0;
}
//this code is for 2nd question
#include <iostream>
#include <sting>
using namespace std;
main()
{
char planet[9][10];
int i,j;
cout <<"enter the palnet name:";
for(i=0;i<9;i++)
{
for(j=0;j<10;j++)
{
cin >> planet[i][j];
}
}
cout <<"the planet names are:";
for(i=0;i<9;i++)
{
cout << *(planet+i);
}
}
note: unfortuantely could not include the screen shots.
for further clarifications kindly get back
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.