C++ in Xcode 1. Create independent return functions that calculate each planetar
ID: 3571502 • Letter: C
Question
C++ in Xcode
1.
Create independent return functions that calculate each planetary body independently.
In main() create a menu that controls the program.
The program should bring receive input only in main() and pass values to other parts of the program.
Create a program that will calculate your weight on Mercury, Venus, Mars, and Earth’s moon.
Label the output so it is clear your weight on each independent planetary body.
program to prompt the user for input instead of assigning the values to variables.
If the user input for weight is 0 or less than prompt the user “Input 0 or less than 0.
Attach a snipping photo of the source code and output
(You are welcome to use the IDE or the Notepad text editor.)
C++
2.
Interest Rate + Principal Calculator
Create a program that will that will calculate Yearly Interest or Compound Interest on a starting principal.
Accept user input in dollars$ in main(). Program should not run if dollar amount > 0. Prompt user and exit the program.)
Your program will have a menu.
**************************************
* Main Menu: *
* Enter # to run program or Quit *
* 1) Yearly Interest Calculator *
* 2) Compound Interest Calculator *
* 3) Quit *
**************************************
Yearly Interest Function: Create a function that accepts 3 arguments.
1 argument will represent savings
1 argument will represent years.
1 argument will represent interest rate.
Function will output each year's principal value. (Output will not be one singular value, but each year’s value.) So if years == 10, there will be 10 outputs.
Compound Interest Function: Create a function that accepts 4 arguments. (Research on compound interest is required.)
1 argument will represent savings
1 argument will represent years
1 argument will represent interest rate.
1 argument will represent number of times it is compounded.
C++
3.
Create independent return functions that calculate each planetary body independently.
In main() create a menu that controls the program.
The program should bring receive input only in main() and pass values to other parts of the program.
WE ARE GOING TO MAKE THE PROGRAM TO INCORPORATE INHERITANCE OOP CONCEPTS.
Create a program that will calculate your weight in Kilograms on Mercury, Venus, Mars, Earth, and each moon connected to the planets.
The program will give the user the choice of planets for weight conversion. If the planet has a moon the program will output the weight on the planet and any moons orbiting the planet.
The user should input weight in pounds.
Create a BaseClass
Create a Derived class for Each planet.
Use getter and setter methods as needed
Try to keep source code in main as minimal as possible.
The program should loop until the user decides to exit the program.
Label the output so it is clear.
If the user input for weight is 0 or less than prompt the user “Input 0 or less than 0 and stop the Program.
Attach a snipping photo of the source code and output
(You are welcome to use the IDE or the Notepad text editor.)
Please enter weight in pounds:
128
**************************************
* Main Menu: *
* Enter # to run program or Quit *
* 1) Calculate Weight on Mercury *
* 2) Calculate Weight on Venus *
* 3) Calculate Weight on Earth *
* 4) Calculate Weight on Mars *
* 5) Quit *
**************************************
3
Weight on Earth is 58.05982336 Kilograms
Weight on Earth’s moon is 8.89041045 Kilograms
**************************************
* Main Menu: *
* Enter # to run program or Quit *
* 1) Calculate Weight on Mercury *
* 2) Calculate Weight on Venus *
* 3) Calculate Weight on Earth *
* 4) Calculate Weight on Mars *
* 5) Quit *
**************************************
Explanation / Answer
1-
#include <iostream>
using namespace std;
void weightmars (int earthplanet){
float marsplanet=0.38*earthplanet;
cout <<" The weight in marsplanet is "<<marsplanet<<endl;
}
float weightmercury(int earthplanet){
float mercuryplanet =0.38*earthplanet;
cout <<" The weight in mercuryplanet is "<<mercuryplanet<<endl;
return mercuryplanet;
}
float weightvenus(int earthplanet){
float venusplanet = 0.91*earthplanet;
cout <<" The weight in Venusplanet is "<<venusplanet<<endl;
return venusplanet;
}
int main(){
int earthplanet;
cout<<"Enter your weight in earth: ";
cin>>earthplanet;
if (earthplanet <=0)
cout<<"Input 0 or less than 0"<<endl;
else{
weightmars (earthplanet);
weightmercury(earthplanet);
weightvenus(earthplanet);
}
return 0;
}
For other questions please provide it as a seprate questions! Thankyou
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.