Question

In: Computer Science

a C++ program that reads in weight in pounds and outputs the equivalent length in Kilograms...

a C++ program that reads in weight in pounds and outputs the equivalent length in Kilograms and grams. 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. 1 pound (lb) is equal to 0.45359237 kilograms (kg). There are 1000 grams in a kilogram, and 16 ounces in a pound

Solutions

Expert Solution

#include<iostream>
using namespace std;
double getInput(){
        double d;
        cout<<"Enter weight in pounds: ";
        cin>>d;
        return d;
}
double convertToKg(double d){
        return d * 0.45359237;
}
void display(double p,double k){
        int kilos= (int)k;
        int grams = (int)((k-kilos)*100);
        cout<<p<<" pounds = "<<kilos<<" kilo and "<<grams<<" grams"<<endl;
}
int main(){
        int ch=1;
        double pounds,kgs;
        do{
                pounds  = getInput();
                kgs = convertToKg(pounds);
                display(pounds,kgs);
                cout<<"Press 1 to continue: ";
                cin>>ch;
        }while(ch==1);
}

NOTE : PLEASE COMMENT BELOW IF YOU HAVE CONCERNS.

I AM HERE TO HELP YOUIF YOU LIKE MY ANSWER PLEASE RATE AND HELP ME IT IS VERY IMP FOR ME


Related Solutions

a C++ program that reads in weight in pounds and outputs the equivalent length in Kilograms...
a C++ program that reads in weight in pounds and outputs the equivalent length in Kilograms and grams. 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. 1 pound (lb) is equal to 0.45359237 kilograms (kg). There are 1000 grams in a kilogram and 16 ounces...
2. Write a C++ program that; Takes in the weight of a person in Kilograms, converts...
2. Write a C++ program that; Takes in the weight of a person in Kilograms, converts and outputs the equivalent weight in pounds. Format your output to 3 decimal places. Your output should look like this 53.000 Kg is equivalent to 123.459 Ibs (Note 1Kg = 2.2046226218488 lbs) Takes in the price of an item on an online store in pound sterling, converts and outputs the equivalent price in U.S dollars. Format your output to 2 decimal places. Your output...
Express your weight in the units of pounds and newtons, and your mass in the units of slugs and kilograms.
Express your weight in the units of pounds and newtons, and your mass in the units of slugs and kilograms.
Write the programs in JavaScript: Write a program that reads a text file and outputs the...
Write the programs in JavaScript: Write a program that reads a text file and outputs the text file with line numbers at the beginning of each line.
Write a program in Java that reads in a set of positive integers and outputs how...
Write a program in Java that reads in a set of positive integers and outputs how many times a particular number appears in the list. You may assume that the data set has at most 100 numbers and -999 marks the end of the input data. The numbers must be output in increasing order. For example, for the data 15 40 28 62 95 15 28 13 62 65 48 95 65 62 65 95 95 -999 The output is...
a)     Write a program that reads a list of integers, and outputs all even integers in the...
a)     Write a program that reads a list of integers, and outputs all even integers in the list. For example, if the input list is [1, 2, 13, 14, 25], the output list should be [2, 14]. b)    Based on your code for part (a), write a program that reads a list of integers, and reports True if all numbers in the list are even, and False otherwise. Example: For input [1, 2, 13, 14, 25], the output should be False. Your...
You need to write a program that reads in two integers from cin and outputs an...
You need to write a program that reads in two integers from cin and outputs an horribly inefficent calculation of the median value. First count from the first number to the second, but stop one short. Then, count from that number back towards the first, again stopping one short. Continue until you reach a single number. Enter 3 and 9 solution: 3456789 987654 45678 8765 567 76 6
You need to write a program that reads in two integers from cin and outputs an...
You need to write a program that reads in two integers from cin and outputs an horribly inefficent calculation of the median value. First count from the first number to the second, but stop one short. Then, count from that number back towards the first, again stopping one short. Continue until you reach a single number.
Using Java Write a program that reads a file of numbers of type int and outputs...
Using Java Write a program that reads a file of numbers of type int and outputs all of those numbers to another file, but without any duplicate numbers. You should assume that the input file is sorted from smallest to largest with one number on each line. After the program is run, the output file should contain all numbers that are in the original file, but no number should appear more than once. The numbers in the output file should...
Using Java Write a program that reads a file of numbers of type int and outputs...
Using Java Write a program that reads a file of numbers of type int and outputs all of those numbers to another file, but without any duplicate numbers. You should assume that the input file is sorted from smallest to largest with one number on each line. After the program is run, the output file should contain all numbers that are in the original file, but no number should appear more than once. The numbers in the output file should...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT