Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can you write an source code for this problem? Create an AddCoins application th

ID: 3653465 • Letter: C

Question




Can you write an source code for this problem?




Create an AddCoins application that prompts the user for the number of pennies, nickels, dimes, and quarters, and then displays their total dollar amount. The AddCoins application should include a getDollarAmount() method that has four int parameters corresponding to the number of pennies, nickels, dimes, and quarters, and returns a String that corresponds to the dollar value of the coins. Note that the String returned should include the currency sign ($). Application output should look similar to: Enter your total coins: Quarters: 3 Dines: 2 Nickels: 1 Pennies: 8 Total: $1. 08

Explanation / Answer

public class AddCoins { DataInputStream dis = new DataInputStream(System.in); int penny,dime,quarter,nickel; float dollar; void start () { try { System.out.println("Enter the number of pennies "); penny = Integer.parseInt(dis.readLine()); System.out.println("Enter the number of dimes"); dime = Integer.parseInt(dis.readLine()); System.out.println("Enter the number of nickels"); nickel = Integer.parseInt(dis.readLine()); System.out.println("Enter the number of quarters"); quarter = Integer.parseInt(dis.readLine()); dollar = (penny+(dime*10)+(nickel*5)+(quarter*25))/100; System.out.println("Total :$"+dollar); } catch(Exception e) { System.out.println(e); } void getDollarAmount(int penny1,int dime1,int quarter1,int nickel1) { float dollar1; dollar1 = (penny1+(dime1*10)+(nickel1*5)+(quarter1*25))/100; System.out.println("Total :$"+dollar1); } } public static void main(String args[]) { AddCoins ac = new AddCoins(); ac.start(); } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote