Question

Write a complete C++ program to converts ounces into pounds and ounces. Prompt the user for...

Write a complete C++ program to converts ounces into pounds and ounces. Prompt the user for the weight in ounces in the main program, pass the ounces to the function called convert(). In the function, convert the ounces to pounds and ounces then display it in the function. (hint: 1 pound = 16 ounces)


Sample output:
Enter ounces:34
2 pound and 2 ounces

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

#include<iostream>

using namespace std;

void convert(int ounces)
{
   int pounds = 0;
   while (ounces >= 16)
   {
       pounds++;
       ounces -= 16;
   }
   cout << pounds << " pound and " << ounces << " ounces\n\n";
}

int main()
{
   cout << "Enter Ounces : ";
   int ounces;
   cin >> ounces;
   convert(ounces);
   cout << "Enter Ounces : ";
   cin >> ounces;
   convert(ounces);
}

COMMENT DOWN FOR ANY QUERIES,

AND LEAVE A THUMBS UP IF THIS ANSWER HELPS YOU.

Add a comment
Know the answer?
Add Answer to:
Write a complete C++ program to converts ounces into pounds and ounces. Prompt the user for...
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 single C++ program that performs the following conversion (The modulus divide will help you...

    Write a single C++ program that performs the following conversion (The modulus divide will help you get the remainder as shown in class) 39 / 12 = 3 and 39 % 12 = 3, so 3 feet 3 inch(es) Height conversion 1 meter = 39 inches 12 inches = 1 foot Ask/Prompt the user to enter in the height in meters, convert and output the result in feet and inches Example 1 meters as input should produce 3 feet (foot)...

  • Write a C program convert.c that converts each number in an array by the sum of...

    Write a C program convert.c that converts each number in an array by the sum of that number plus 6 modulus 10. A sample input/output: Enter the length of the array: 5 Enter the elements of the array: 3 928 4 14 77 Output: 9 4 0 0 3 The program should include the following function: void convert(int *a1, int n, int *a2) The function converts every element in array a1 of length n to an output array a2. The...

  • python - Write a program that converts square feet to square yards. Prompt the user to...

    python - Write a program that converts square feet to square yards. Prompt the user to enter a value in square feet and then print the converted output along with a message similar to "1 sq. ft. is .11111 sq. yards."

  • C++ Write a complete program that will prompt the user for a digit in the range...

    C++ Write a complete program that will prompt the user for a digit in the range 5 to 15. Using that digit to determin scale display the graphic shown below. Your program must use a nested loop. You may not use the string class SAMPLE RUN: Input an integer in the range 5 to 20: 100 Incorrect. The number is out of range. Input an integer in the range 5 to 20: 10 * ** *** **** ***** ****** *******...

  • Write a Java program that performs these operations Prompt the user to enter a low height...

    Write a Java program that performs these operations Prompt the user to enter a low height in feet (an integer) Prompt the user to enter a high height in feet (an integer) Prompt the user to enter a low weight in pounds (an integer) Prompt the user to enter a high weight in pounds (an integer) Print a table of Body Mass Index (BMI) for the heights and weights entered, ranging from the low height to the high height (inclusive),...

  • 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;...

  • Python Programming 4th Edition: Write a program that asks the user for the number of feet....

    Python Programming 4th Edition: Write a program that asks the user for the number of feet. The program converts those feet to inches by using the formula ’12 * feet’. Hint: Define main () program Get the number of feet from the user Define variables Call a function feet_to_inches(feet) The function receives the number of feet and returns the number of inches in that many feet. The output should look like as follows: Enter the number of feet: If the...

  • 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...

  • This is in C++. Example: You will write a program that will prompt the user to...

    This is in C++. Example: You will write a program that will prompt the user to enter a grade out of 100 and then show them what the equivalent grade points value is. The main() function will handle the input and output tasks, but the actual conversion will occur in a function called GradePoints(). GradePoints Specifications This function is strictly a processing function, meaning that there are no console input or output steps in the actual function. Consider that this...

  • Write C++ program to prompt user to enter a 3-digits number, say 371, to a variable...

    Write C++ program to prompt user to enter a 3-digits number, say 371, to a variable called num. Then store each digit of this inputted number to three different variables called digit1, digit2 and digit3. Hence, when number entered is 371, digit1 is 3, digit2 is 7 and digit3 is 1. Display the value of inputted number followed by digit1, digit2 and digit3. Hint: You have to use / and % operator in this question.

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