Input the number of quarters dimes nickels and pennies from


Tasks

Write a program that prints

Lab 2 written by YOURNAME and calls two methods:

1. Input the number of quarters, dimes, nickels, and pennies from the user. Print out the number of coins and total value in dollars.

2. Input the number of cents from the user. Determine and print out the number of quarters, dimes, nickels, and pennies to add up to that number of cents. No, you can't use all pennies.

You should have local variables for each value that is entered and each value that you calculate. For example, for the first method there should be a local variable that stores the total dollar amount of the change, as well as a local variable for the total number of coins.

For the second method, we can use integer division and the mod operator to make change. Suppose the user enters 99 as the number of cents. The sequence of calculations should be as follows.

1) The integer division 99 / 25 can be used to determine the number of quarters (3).

2) Using the mod operator 99 % 25 determines the remaining number of cents to be converted into change (24).

3) Integer division 24 / 10 can be used again to determine the number of dimes (2).

4) The mod operator 24 % 10 can be used again to determine the remaining amount (4).

5) Next, for nickels, integer division 4 / 5 for the number of nickels (0) and a mod operation 4 % 5 for the remaining amount (4).

6) Whatever is left is the number of pennies (4).

 

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Input the number of quarters dimes nickels and pennies from
Reference No:- TGS02944994

Expected delivery within 24 Hours