Question

Input the amount of purchase which is less than P100.00. Create a java program that will...

Input the amount of purchase which is
less than P100.00. Create a java program
that will calculate the change of P100.00
given by the customer with the
following breakdown:
P 50.00 - _______________;
P 20.00 - _______________;
P 10.00 - _______________;
P 5.00 - _______________;
P 1.00 - _______________;
Note: Purchases are all in pesos. No
centavos.
Formula Hint: Apply the concept of
modulus operator

Homework Answers

Answer #1

import java.util.*;

public class Main {
public static void main(String[] args) throws Exception {
// Your code here!
Scanner sc= new Scanner(System.in);
int change=sc.nextInt();
if(change<=100){

  
int p50 = Math.round((int)change/50);
change=change%50;
int p20 = Math.round((int)change/20);
change=change%20;
int p10 = Math.round((int)change/10);
change=change%10;
int p5 = Math.round((int)change/5);
change=change%5;
int p1 = Math.round((int)change/1);

System.out.println("P50 " + p50);
System.out.println("P20: " + p20);
System.out.println("P10: " + p10);
System.out.println("P5: " + p5);
System.out.println("P1: " + p1);
}
else{
System.out.println("Input is must be less than equal to 100");
}
}
}

Know the answer?
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
Similar Questions
Construct a C program which computes the minimum number of bills and coins needed to make...
Construct a C program which computes the minimum number of bills and coins needed to make change for a particular purchase. The cost of the item is $21.17 and the amount tendered is $100.00. These values should be built into your program using assignment statements rather than input into the program during program runtime. Your program should indicate how many bills and coins of each denomintaion are needed for the change. You should make use of the following denominations: Bills:...
Create a Change application that prompts the user for an amount less than $1.00 and then...
Create a Change application that prompts the user for an amount less than $1.00 and then displays the minimum number of coins necessary to make the change. The change can be made up of quarters, dimes, nickels, and pennies. The application output should look similar to: Enter the change in cents: 212 The minimum number of coins is: Quarters: 8 Dimes: 1 Nickels 0 Pennies: 2 Must be coded in Java please
Complete a Java program named ARMgr that maintains customer accounts receivable in a database. The code...
Complete a Java program named ARMgr that maintains customer accounts receivable in a database. The code to initialize the CustomerAccountsDB database table and add a set of customer accounts is provided. Finish the code in these 3 methods in CustomerAccountDB.java to update or query the database: -purchase(double amountOfPurchase) -payment(double amountOfPayment) -getCustomerName() Hint: For getCustomerName(), look at the getAccountBalance() method to see an example of querying data from the database. For the purchase() and payment() methods, look at the addCustomerAccount() method...
Assessment Module 9 – Marginal Analysis Please create a tab in your Excel Workbook and name...
Assessment Module 9 – Marginal Analysis Please create a tab in your Excel Workbook and name it “Module 9 Marginal Analysis.” You have same basic templates in your Resources workbook, but you may need to modify these to fit the individual business problem. I am evaluating your professional ability to do so, and to create professional models and reports, so take your time, think through a logical, clear, well-structured, well-formatted model. Remember, assumption tables (like T-accounts) are your friends! Be...
In February 2012, the Pepsi Next product was launched into the US market. This case study...
In February 2012, the Pepsi Next product was launched into the US market. This case study provides students with an interesting insight into PepsiCo’s new product process and some of the challenging decisions that they faced along the way. Pepsi Next Case Study Introduction Pepsi Next was launched by PepsiCo into the US market in February 2012, and has since been rolled out to various international markets (for instance, it was launched in Australia in September 2012). The new product...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT