//i was trying the use the functions for this particual program but i keep //getting erros in it even after reading the textbook can you please help me //thank you.
#include <iostream>
usingnamespace std;
//prototyping all the functions
void PoundstoNewtons();
void FeettoMeters();
void MilestoKilometers();
void MenuAndSelection(char choice);
void doSelection(char selection);
//calling the functions
int main()
{
cout<<MenuAndSelection();
return 0;
}
//Givint the user a choice for a selection in a function
void MenuAndSelection(char choice){
cout<<"P Pounds to Newtons"<<endl<<"F Feet to Meters"<<endl<<"M miles to Kilometers"<<endl;
cin>>choice;
}
//using a switch to take the characters from the choice and directiong it to the functions
void doSelection(char selection){
switch (selection){
case'P':
PoundstoNewtons();
break;
case'F':
FeettoMeters();
break;
case'M':
MilestoKilometers();
break;
default:
cout<<"There is no such choice"<<endl;
break;
}
}
//function fot pounds to newtons
void PoundstoNewtons(){
constdouble NewtonPP = 4.9;
double Pounds = 0.0;
double Newtons = 0.0;
cout<<"Plese enter a value for pound:";
cin>>Pounds;
Newtons=Pounds*NewtonPP;
cout<<"The valuse in pounds which you entered is:"<<Pounds<<endl;
cout<<"The value in Newtons is:"<<Newtons<<endl;
}
//function for feet to meters
void FeettoMeters(){
constdouble FeetPP = 3.28;
double Feet = 0.0;
double Meters = 0.0;
cout<<"Plese enter a value for Meters:";
cin>>Meters;
Feet=Meters*FeetPP;
cout<<"The valuse in Meters which you entered is:"<<Meters<<endl;
cout<<"The value in Feet is:"<<Feet<<endl;
}
//function for miles to kilometers
void MilestoKilometers(){
constdouble Milespp = 1.61;
double Miles = 0.0;
double Kilometers = 0.0;
cout<<"Plese enter a value for Kilometers:";
cin>>Kilometers;
Miles=Kilometers*Milespp;
cout<<"The valuse in Kilometers which you entered is:"<<Kilometers<<endl;
cout<<"The value in Miles is:"<<Miles<<endl;
}
#include <iostream>
usingnamespace std;
//prototyping all the functions
void PoundstoNewtons();
void FeettoMeters();
void MilestoKilometers();
void MenuAndSelection(char choice);
void doSelection(char selection);
//calling the functions
int main()
{
MenuAndSelection('M');
doSelection('M'); //i want it to run without me enter a char variable
//i want it to get the value from MenuandSelection
//and use it in doSelection instead of 'M'
return 0;
}
//Givint the user a choice for a selection in a function
void MenuAndSelection(char choice){
cout<<"P Pounds to Newtons"<<endl<<"F Feet to Meters"<<endl<<"M miles to Kilometers"<<endl<<"Please enter your choice from the menu above:";
cin>>choice;
}
//using a switch to take the characters from the choice and directiong it to the functions
void doSelection(char selection){
switch (selection){
case'P':
PoundstoNewtons();
break;
case'F':
FeettoMeters();
break;
case'M':
MilestoKilometers();
break;
default:
cout<<"There is no such choice"<<endl;
break;
}
}
//function fot pounds to newtons
void PoundstoNewtons(){
constdouble NewtonPP = 4.9;
double Pounds = 0.0;
double Newtons = 0.0;
cout<<"Plese enter a value for pound:";
cin>>Pounds;
Newtons=Pounds*NewtonPP;
cout<<"The valuse in pounds which you entered is:"<<Pounds<<endl;
cout<<"The value in Newtons is:"<<Newtons<<endl;
}
//function for feet to meters
void FeettoMeters(){
constdouble FeetPP = 3.28;
double Feet = 0.0;
double Meters = 0.0;
cout<<"Plese enter a value for Meters:";
cin>>Meters;
Feet=Meters*FeetPP;
cout<<"The valuse in Meters which you entered is:"<<Meters<<endl;
cout<<"The value in Feet is:"<<Feet<<endl;
}
//function for miles to kilometers
void MilestoKilometers(){
constdouble Milespp = 1.61;
double Miles = 0.0;
double Kilometers = 0.0;
cout<<"Plese enter a value for Kilometers:";
cin>>Kilometers;
Miles=Kilometers*Milespp;
cout<<"The valuse in Kilometers which you entered is:"<<Kilometers<<endl;
cout<<"The value in Miles is:"<<Miles<<endl;
}
//calling the functions
int main()
{
char Menu = 0; //the char that you will pass to the functions
MenuAndSelection(Menu);
doSelection(Menu);
return 0;
};
Then you will need to modify your functions to take a reference to a char: