Advertisement
KeeganT

Ch7Ex5

Mar 19th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. package ch7ex5;
  2. import java.util.Scanner;
  3.  
  4. public class Ch7Ex5
  5. {
  6.     public static double getDollarAmount(double q, double d, double n, double p)
  7.     {
  8.         double num=(q*0.25)+(d*0.1)+(n*0.05)+(p*0.01);
  9.         return num;
  10.     }
  11.     public static void main(String[] args)
  12.     {
  13.         Scanner sc=new Scanner(System.in);
  14.         System.out.println("Enter your total coins: ");
  15.         System.out.println("Quarters: ");
  16.         double q=sc.nextInt();
  17.         System.out.println("Dimes: ");
  18.         double d=sc.nextInt();
  19.         System.out.println("Nickels: ");
  20.         double n=sc.nextInt();
  21.         System.out.println("Pennies: ");
  22.         double p=sc.nextInt();
  23.         System.out.print("Total: $");
  24.         System.out.printf("%.2f",getDollarAmount(q,d,n,p));
  25.         System.out.println();
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement