Question

Write a function PoundsToKilograms that: Takes a number of pounds (an integer) as a parameter, Calculates...

Write a function PoundsToKilograms that: Takes a number of pounds (an integer) as a parameter, Calculates and returns the corresponding value in kilograms. 1 kilogram is equal to 2.2 pounds. In the main section of the program: Prompt the user to input a weight in pounds, Call the function you wrote to transform the weight into kilograms, Output the weight in kilograms; the number must be shown with 2 decimals after the decimal point. Your program must define and call the PoundsToKilograms function, not only do input/output and transform correctly pounds to kilograms. Here is an example of one run of the code: Enter weight in pounds: 130 # this is user input 130 pounds is 59.09 kilograms. # this is program output

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
#include <iomanip>

using namespace std;
float PoundsToKilograms(int pounds)
{
   float k=pounds/2.2;
   return k;
}
int main() {
   int pounds;
   float kilograms;
   cout<<"Enter weight in pounds : ";
   cin>>pounds;
   kilograms=PoundsToKilograms(pounds);
cout <<fixed;
cout <<setprecision(2);
   cout<<"the "<<pounds <<" pounds is "<<kilograms<<" kilograms";
   return 0;
}

// OUTPUT

// If any doubt please comment

Add a comment
Know the answer?
Add Answer to:
Write a function PoundsToKilograms that: Takes a number of pounds (an integer) as a parameter, Calculates...
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 function that takes an integer input n as a parameter and after it calculates...

    Write a function that takes an integer input n as a parameter and after it calculates the sum of 1+2+3+...+n, it returns the value to the main program. For example, if n=4, the output of the sum will be 10.

  • An airline company needs a program to convert pounds to kilograms for passengers to determine baggage...

    An airline company needs a program to convert pounds to kilograms for passengers to determine baggage weight in kilograms. Write a C++ program that displays the prompt: Enter pounds. After the user responds to the prompt, the program should calculate the number of kilograms and display the result with a short message. One kilogram = 2.2 pounds. The program should then determine the cost of the bag, which is $3.00 per kilogram if the bag weighs more than 21 kilograms;...

  • In HTML write a program that calculates and displays all factors of a number with a...

    In HTML write a program that calculates and displays all factors of a number with a function. A factor is any number that divides into a number evenly. For examples: Factors of 20 are 1,2,4,5,10,20 For the program: Prompt the user for a number or use an input Call a function to calculate all factors using loops and conditionals and modulus Display all factors to the page Bonus +5 If the factor is Even : Print it in Green If...

  • Write a Python program to prompt the user for an integer number. Assign this integer to...

    Write a Python program to prompt the user for an integer number. Assign this integer to a variable X. Then assign a variable Y to the X**3 (X to the power 3). Finally, assign the variable Z to the square root of Y and print the values of X, Y, and Z as shown in the example below. Use main() function to define and call the program. Example: Enter an integer number: 3 X = 3 if Y=X**3 then Y...

  • Goals: Practicing functions and parameter types. Problem: You are to create a program that will aid...

    Goals: Practicing functions and parameter types. Problem: You are to create a program that will aid in a farmer in monitoring the amount of corn to feed livestock each week. There is a template named "Labs1-5template.cpp" posted on Canvas which you should download and complete. Follow the instructions given in the template and follow the assignment guidelines for the course. Do not use global variables and do not use the same variable name in multiple functions. Your finished code should...

  • (C++) Write a function, remove, that takes three parameters: an array of integers, the number of...

    (C++) Write a function, remove, that takes three parameters: an array of integers, the number of elements in the array, and an integer (say, removeItem). The function should find and delete the first occurrence of removeItem in the array. (Note that after deleting the element, the number of elements in the array is reduced by 1.) Assume that the array is unsorted. Also, write a program to test the function. Your program should prompt the user to enter 10 digits...

  • ZYBOOKS LAB: 10.23.1 Hello, I'm trying to solve this problem with creating a program code in...

    ZYBOOKS LAB: 10.23.1 Hello, I'm trying to solve this problem with creating a program code in Python about People's Weights. Here is the question: 10.23 LAB: Warm up: People's weights (Lists) (1) Prompt the user to enter four numbers, each corresponding to a person's weight in pounds. Store all weights in a list. Output the list. (2 pts) Ex: Enter weight 1: 236.0 Enter weight 2: 89.5 Enter weight 3: 176.0 Enter weight 4: 166.3 Weights: [236.0, 89.5, 176.0, 166.3]...

  • Write a program in MIPs Assembly Language to compute nth number of a fibonacci number sequence....

    Write a program in MIPs Assembly Language to compute nth number of a fibonacci number sequence. Your program should prompt for an integer input n from the user. The program should call a recursive function to compute the nth fibonacci number. Your program must follow programming convention. You should submit program and screenshot of output in a single word/pdf file. You should use following recursive definition of fibonacci function: fib(0) = 0 fib(1) = 1 fib(n) = fib(n-1) +fib(n-2)

  • Write a function that takes as an input parameter an integer that will represent the length...

    Write a function that takes as an input parameter an integer that will represent the length of the array and a second integer that represents the range of numbers the random number should generate (in other words, if the number is 50, the random number generator should generate numbers between 0 and 49 including 49. The function then sorts the list by traversing the list, locating the smallest number, and printing out that smallest number, then replacing that number in...

  • Python Programming 4th Edition Write a program that calculates the length of a right triangle's hypotenuse....

    Python Programming 4th Edition Write a program that calculates the length of a right triangle's hypotenuse. Hints: Define main() program Get the length of the triangle’s two sides (user input) Call math function to calculate the length of the hypotenuse. The output should look like as follows: The length of the hypotenuse is 12.041594578792296

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