Question

. Write a program that reads in a length in feet and inches and outputs the...

. Write a program that reads in a length in feet and inches and outputs the
equivalent length in meters and centimeters. Use at least three functions:
one for input, one or more for calculating, and one for output. Include a
loop that lets the user repeat this computation for new input values until
the user says he or she wants to end the program. There are 0.3048 meters
in a foot, 100 centimeters in a meter, and 12 inches in a foot.

in C++ (Cpp)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>

using namespace std;

void getData(double& feet,double& inches)

{

cout<<"Enter length in feet"<<endl;

cin>>feet;

cout<<"Enter length in inches"<<endl;

cin>>inches;

}

void convert(double feet,double inches,double& meter,double& centimeter)

{

meter=feet*0.3048;

centimeter=inches*2.54;

}

void printData(double feet,double inches,double meter,double centimeter)

{

cout<<feet<<" feet "<<inches<<" inches= "<<meter<<" meters and "<<centimeter<<" centimeters."<<endl;

}

int main() {

double feet,inches,meter,centimeter;

char check;

do

{

getData(feet,inches);

convert(feet,inches,meter,centimeter);

printData(feet,inches,meter,centimeter);

cout<<"Do you want to continue(press y or Y)?: ";

cin>>check;

}while(check=='y'||check=='Y');

}

Output

Add a comment
Know the answer?
Add Answer to:
. Write a program that reads in a length in feet and inches and outputs the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that prompts the user to enter a length in feet and inches and...

    Write a program that prompts the user to enter a length in feet and inches and outputs the equivalent length in centimeters. If the user enters a negative number or a nondigit number, throw and handle an appropriate exception and prompt the user to enter another set of numbers. Using Python

  • c++ Write a program that prompts the user to enter a length in feet and then...

    c++ Write a program that prompts the user to enter a length in feet and then enter a length in inches and outputs the equivalent length in centimeters. If the user enters a negative number or a non-digit number, throw and handle an appropriate exception and prompt the user to enter another set of numbers. Your error message should read A non positive number is entered and allow the user to try again.

  • Write a Program that has a menu with a  layout below, that asks the user if they...

    Write a Program that has a menu with a  layout below, that asks the user if they want to: 1. Converts from feet and inches to meter and centimeters 2. Converts from meter and centimeters to feet and inches 3. Quit the program The program should continue as long as the user asks it to. The program will use a switch statement for the menu option selection. Either a do loo or a do-while loop can be used for the overall...

  • I have this c++ program that i have to create but i am stuck on it....

    I have this c++ program that i have to create but i am stuck on it. Write a height conversion program that shall allow user to convert from feet and inches to meters (option 1) and vice versa (option 2). User shall be able to specify the type of conversion (a menu of two options). Display an error message if an invalid option is specified. Otherwise, the program would read in a length in feet and inches (two separate integer...

  • Write a Java program that reads in a word from the user and outputs each character...

    Write a Java program that reads in a word from the user and outputs each character of the word on a separate line. For example, if the user enters the input "Joe", your program should output: J o e You need to use a for-loop.

  • Part l: Assignment and Variables Answer only one question from t this part (1 or 2)...

    Part l: Assignment and Variables Answer only one question from t this part (1 or 2) fence is 30 T does not know how to change feet to meters, so he asked you to farm's length and width in feet and calculates and prints the cost Note: One foot is equal to 0.3048 meter. arm: A farmer wants to put a fence around his farm and the cost dirnams. The farmer knows the dimensions of his rectangular shaped farm in...

  • Java COSC 237 Problem: You are to develop a program that allows a user to convert...

    Java COSC 237 Problem: You are to develop a program that allows a user to convert lengths in the metric system (i.e., meters/centimeters) to the Imperial system (i.e., feet/inches) AND convert lengths in the Imperial system to the metric system. Specifications • Input may be given with or without decimal places. • Error checking for invalid input is not required. • The results are to be displayed with two decimal places of precision. (For example, 2 meters, 25 centimeters (225...

  • Need help with following C++ program: 3) Write a program in C++ with a menu. When...

    Need help with following C++ program: 3) Write a program in C++ with a menu. When the program executes it gives the user a list of choice to choose from. The user can input 1,2 or 3 only. For all other input, the message “Invalid Options” will be displayed. ****MENU**** 1) Convert length from feet to inches. 2) Convert length from meter to centimeters. 3) To quit the program

  • C++ programming language , I need help writing the code . Please explain if you can...

    C++ programming language , I need help writing the code . Please explain if you can . Exercise 10: Unit conversion (10 points) Write a console program that converts meters into feet and inches. The program starts by asking the user for a measurement in meters. The program should accept a floating point number. After getting the number, the program computes the number of feet and inches equal to the specified number of meters. The program outputs feet and inches...

  • Write a program (C++) that requests the current time and a waiting time as two integers...

    Write a program (C++) that requests the current time and a waiting time as two integers for the number of hours and the number of minutes to wait. The program then outputs what the time will be after the waiting period. Use 24-hour notation for the times. Include a loop that lets the user repeat this calculation for additional input values until the user says she or he wants to end the program.You can assume the wait time will always...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT