Question: Write a program to: Prompt the user for two positive integers, divide the larger by the smaller, and print the answer as a quotient and
Write a program to:
Prompt the user for two positive integers, divide the larger by the smaller, and print the answer as a quotient and remainder.
Use main( ) as the driver function. Allow the user to run the program as many times as desired.
Write 5 functions that main( ) calls to accomplish the task:
getIntegers( ): Prompts the user for two positive integers. Use reference parameters.
findLargeAndSmall( ): Determines which of the integers is larger and which is smaller. Returns the larger and smaller integers via reference parameters.
calcQuotient( ): Calculates and returns the quotient of the larger integer divided by the smaller.
calcRemainder( ): Calculates and returns the remainder of the larger integer divided by the smaller.
displayResults( ): Prints the quotient and the remainder in the form typically used for long division problems in grade school. e.g. The answer for 7/2 is displayed as 3 R1.
Sample I/O:
**************************************************************
This program will ask you to enter two positive integers.
It will divide the larger by the smaller and display the
result as a quotient and remainder.
**************************************************************
Please enter your first integer and press
Please enter your second integer and press
The answer for 9/5 is 1 R 4
Would you like to process another set of numbers (Y or N)? y
**************************************************************
This program will ask you to enter two positive integers.
It will divide the larger by the smaller and display the
result as a quotient and remainder.
**************************************************************
Please enter your first integer and press
Please enter your second integer and press
The answer for 7/2 is 3 R 1
Would you like to process another set of numbers (Y or N)? y
**************************************************************
This program will ask you to enter two positive integers.
It will divide the larger by the smaller and display the
result as a quotient and remainder.
**************************************************************
Please enter your first integer and press
Please enter your second integer and press
The answer for 5/3 is 1 R 2
Would you like to process another set of numbers (Y or N)? n
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
