Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pr.wk02;
- import java.util.Scanner;
- public class number04 {
- public static void main(String[] args) {
- int quarters;
- int dimes;
- int nickels;
- int pennies;
- double dollars;
- Scanner rdc = new Scanner(System.in);
- System.out.print("Enter the number of quarters: ");
- quarters = rdc.nextInt();
- rdc.nextLine();
- System.out.print("Enter the number of dimes: ");
- dimes = rdc.nextInt();
- rdc.nextLine();
- System.out.print("Enter the number of nickels: ");
- nickels = rdc.nextInt();
- rdc.nextLine();
- System.out.print("Enter the number of pennies: ");
- pennies = rdc.nextInt();
- rdc.nextLine();
- dollars = (0.25 * quarters) + (0.10 * dimes) + (0.05 * nickels) + (0.01 * pennies);
- System.out.println();
- System.out.print("The total in dollars is $");
- System.out.printf("%1.2f", dollars);
- System.out.println();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement