Create a program called Bariya.java that will ask the user toinput the number of
ID: 3615840 • Letter: C
Question
Create a program called Bariya.java that will ask the user toinput the number of units per Philippine Peso denomination andcompute its total Peso value. Your program should then output thetotal Peso value and the break down of the same total Peso valuewith the least possible number of units per denomination. Sample run: Please enter number of P1000 bills: 1 Please enter number of P500 bills: 2 Please enter number of P200 bills: 3 Please enter number of P100 bills: 4 Please enter number of P50 bills: 5 Please enter number of P20 bills: 6 Please enter number of P10 coins: 7 Please enter number of P5 coins: 8 Please enter number of P1 coins: 9 The total value entered is P3489. This total value breaks down to: 3 - P1000 2 - P200 1 - P50 1 - P20 1 - P10 1 - P5 4 - P1 Create a program called Bariya.java that will ask the user toinput the number of units per Philippine Peso denomination andcompute its total Peso value. Your program should then output thetotal Peso value and the break down of the same total Peso valuewith the least possible number of units per denomination. Sample run: Please enter number of P1000 bills: 1 Please enter number of P500 bills: 2 Please enter number of P200 bills: 3 Please enter number of P100 bills: 4 Please enter number of P50 bills: 5 Please enter number of P20 bills: 6 Please enter number of P10 coins: 7 Please enter number of P5 coins: 8 Please enter number of P1 coins: 9 The total value entered is P3489. This total value breaks down to: 3 - P1000 2 - P200 1 - P50 1 - P20 1 - P10 1 - P5 4 - P1Explanation / Answer
please rate - thanks import java.io.*; public class untitled { public static void main(String[] args) throwsException { BufferedReader keyIn =new BufferedReader(new InputStreamReader(System.in)); intP1000,P500,P200,P100,P50,P20,P10,P5,P1,amount,num; String input; System.out.print("Pleaseenter number of P1000 bills: "); input= keyIn.readLine(); P1000=Integer.parseInt(input); System.out.print("Please enternumber of P500 bills: "); input= keyIn.readLine(); P500=Integer.parseInt(input); System.out.print("Pleaseenter number of P200 bills: "); input= keyIn.readLine(); P200=Integer.parseInt(input); System.out.print("Pleaseenter number of P100 bills: "); input= keyIn.readLine(); P100=Integer.parseInt(input); System.out.print("Pleaseenter number of P50 bills: "); input= keyIn.readLine(); P50=Integer.parseInt(input); System.out.print("Pleaseenter number of P20 bills: "); input= keyIn.readLine(); P20=Integer.parseInt(input); System.out.print("Please enternumber of P10 bills: "); input= keyIn.readLine(); P10=Integer.parseInt(input); System.out.print("Please enternumber of P5 bills: "); input= keyIn.readLine(); P5=Integer.parseInt(input); System.out.print("Please enternumber of P1 bills: "); input= keyIn.readLine(); P1=Integer.parseInt(input); amount=P1000*1000+P500*500+P200*200+P100*100+P50*50+P20*20+P10*10+P5*5+P1; System.out.println("The totalvalue entered is "+amount); System.out.println(" This totalvalue breaks down to:"); num=amount/1000; if(num!=0) System.out.println(num+" - P1000"); amount%=1000; num=amount/500; if(num!=0) System.out.println(num+" - P500"); amount%=500; num=amount/200; if(num!=0) System.out.println(num+" - P200"); amount%=200; num=amount/100; if(num!=0) System.out.println(num+" - P100"); amount%=100; num=amount/50; if(num!=0) System.out.println(num+" - P50"); amount%=50; num=amount/20; if(num!=0) System.out.println(num+" - P20"); amount%=20; num=amount/10; System.out.println(num+" -P10"); amount%=10; num=amount/5; if(num!=0) System.out.println(num+" - P5"); amount%=5; if(num!=0) System.out.println(amount+" - P1"); } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.