Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ch7ex5;
- import java.util.Scanner;
- public class Ch7Ex5
- {
- public static double getDollarAmount(double q, double d, double n, double p)
- {
- double num=(q*0.25)+(d*0.1)+(n*0.05)+(p*0.01);
- return num;
- }
- public static void main(String[] args)
- {
- Scanner sc=new Scanner(System.in);
- System.out.println("Enter your total coins: ");
- System.out.println("Quarters: ");
- double q=sc.nextInt();
- System.out.println("Dimes: ");
- double d=sc.nextInt();
- System.out.println("Nickels: ");
- double n=sc.nextInt();
- System.out.println("Pennies: ");
- double p=sc.nextInt();
- System.out.print("Total: $");
- System.out.printf("%.2f",getDollarAmount(q,d,n,p));
- System.out.println();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement