Question
i need to do this for java get remaining amount in pennies for each bill i got this so far Write an application that reads
i need to do this for java get remaining amount in pennies for each bill i got this so far
Write an application that reads a monetary amount, and then determines the fewest number of each bill and coin needed to represent that amount, starting with the highest (assuming $10 bill is the maximum size needed).
Next, use the equivalent penny amount to calculate the fewest number of $10 bill in a division operation, and then calculate the remaining balance in a remainder operation. The remaining balance should be used to calculate the next number.
package project01; /*** program displays monetary values * @author alary johnson ics201 *@version01 */ import java.util.Scanner; public class project { public static void main(String[] args) { // TODO Auto-generated method stub double originalamount,penniesamount; int one,five,ten; int penny,nickel,dime,quarter; Scanner scan = new Scanner(System.in); System.out.print("What is the amount?"); originalamount= scan.nextDouble(); ten = (int) originalamount/10; originalamount= originalamount%1; five = (int) originalamount/5; originalamount = originalamount%5; one = (int) originalamount/1; originalamount=originalamount%1; quarter = (int) (originalamount/0.25); originalamount = originalamount%25; dime = (int) (originalamount/0.10); originalamount=originalamount%10; nickel = (int) (originalamount/0.5); originalamount = originalamount%5; penny = (int) (originalamount/0.1); originalamount = originalamount%5; System.out.println (ten + "ten dollar bills"); System.out.println(five + "five dollar bills"); System.out.println(one + "one dollar bills"); System.out.println(quarter +"quarters"); System.out.println(dime +"dimes"); System.out.println(nickel+ "nickels"); System.out.println(penny + "pennies"); System.out.println ("This is equivalent to:"); int penniesamount1 = (int) (originalamount * 100); int originalamount1 = penniesamount1 / 100; double originalAmount = originalamount1 - penniesamount1 * 1000; System.out.println("remaining amount in pennies:"+ remainingAmount); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started