Question
#include using namespace std; // Constant factor converting feet to meters: 3.28 feet = 1 meter const double FEET_TO_METERS_FACTOR = 0.304878048; // (1 / 3.28)
#include
using namespace std;
// Constant factor converting feet to meters: 3.28 feet = 1 meter
const double FEET_TO_METERS_FACTOR = 0.304878048; // (1 / 3.28)
// TODO: Declare 4 function prototypes
// - Name: getFeet
// Parameters:
// Returns: an int for the number of feet entered by the user
// - Name: getInches
// Parameters:
// Returns: a double for the number of inches entered by the user
// - Name: convertToMeters
// Parameters:
// - 1 int for feet (pass by value)
// - 1 double for inches (pass by value)
// Returns: a double for the number of meters
// - Name: displayResults
// Parameters:
// - 1 int for feet (pass by value)
// - 1 double for inches (pass by value)
// - 1 double for meters (pass by value)
// Returns:
// ********************************************
int main()
{
// Declare program variables.
int feet;
double inches, meters;
// TODO: Call function to get feet input.
// An int value is returned - assign to the correct variable
// TODO: Call function to get inches input.
// A double value is returned - assign to the correct variable
// TODO: Call function to convert feet and inches to meters.
// Pass the two arguments to the function
// Assign the returned value to the correct variable
// TODO: Call function to print the results.
// Pass the correct three arguments to the function
// Nothing is returned, so do NOT provide a variable assignment
cout << "End program - ";
return 0;
}
// ********************************************
// TODO: Define getFeet()
// Refer to the function prototype above for parameter and return type info
//
// Repeat
// - Prompt the user to enter feet
// - Read the user's keyboard response
// Until a value of 0 or more is entered
//
// Note: You will need to declare a local variable inside the function to hold
// the user's entry for feet (be sure to use correct data type)
// TODO: Define getInches()
// Refer to the function prototype above for parameter and return type info
//
// Repeat
// - Prompt the user to enter inches
// - Read the user's keyboard response
// Until a value of 0 or more and less than 12 is entered
//
// Note: You will need to declare a local variable inside the function to hold
// the user's entry for inches (be sure to use correct data type)
// TODO: Define convertToMeters()
// Refer to the function prototype above for parameter and return type info
//
// - Declare a new local variable called fractionalFeet that is type double
// - Type cast feet to be a double and assign to the fractionalFeet variable
// - On the same line where you are assigning the converted feet value to
// - fractionalFeet, also convert inches to feet (inches / 12) and add to the feet
// - Finally, return the result of multiplying fractionalFeet by FEET_TO_METERS_FACTOR
// TOTO: Define displayResults()
// Output statement to format results as shown
// using values passed to parameters:
// e.g.
//
// 10'-6.25" = 3.20757 meter(s).
//
// Use string literals along with value parameters:
// "'"
// "\" = "
// " meter(s)."
/* Sample Output
Sample Run #1:
=====================
Enter feet: 5
Enter inches: 10.25
5'-10.25" = 1.78481 meter(s).
End program - Press any key to continue . . .
Sample Run #2:
=====================
Enter feet: -5
Enter feet: 3
Enter inches: -5
Enter inches: 15.75
Enter inches: 5.75
3'-5.75" = 1.06072 meter(s).
End program - Press any key to continue . . .
*/
So, this is the problem and I got this so far.... and there are two errors that it says
warning C4700: uninitialized local variable 'meters' used warning C4700: uninitialized local variable 'fractionalFeet' used
#include
using namespace std;
const double FEET_TO_METERS_FACTOR = 0.304878048;
int getFeet();
double getInches();
double convertToMeters(int feet, double inches);
void displayResults(int feet, double inches, double meters);
int main()
{
int feet;
double inches, meters;
feet = getFeet();
inches = getInches();
double getInches = (inches);
convertToMeters(feet, inches);
displayResults(feet, inches, meters);
cout << "End program - ";
return 0;
}
int getFeet()
{
int feet;
cout << "Enter feet: ";
cin >> feet;
while (feet <= 0)
{
cout << "Enter feet: ";
cin >> feet;
}
return feet;
}
double getInches()
{
double inches;
cout << "Enter inches: ";
cin >> inches;
while (inches <= 0 && inches > 12)
{
cout << "Enter inches: ";
cin >> inches;
}
return inches;
}
double convertToMeters(int feet, double inches)
{
double fractionalFeet;
double cast_feet(fractionalFeet);
double(fractionalFeet * FEET_TO_METERS_FACTOR);
return fractionalFeet;
}
void displayResults(int feet, double inches, double meters)
{
cout << feet << "- " << inches << "= " << meters << "meter(s)." << endl;
}
Plz somebody helps me
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started