• API
• FAQ
• Tools
• Archive
daily pastebin goal
51%
SHARE
TWEET

# Untitled

a guest Jan 18th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. //Exam 1 - Problem 3
2. //Jeffrey Davis
3.
4. import java.util.*;
5. import java.text.*;
6.
7. public class exam1problem3
8. {
9.     public static void main(String [] args)
10.     {
11.
12.     Scanner scanIn = new Scanner(System.in);
13.
14.     int totalCents, halfDollars, quarters, dimes, nickels, pennies, remainder;
15.
16.     System.out.print("Enter your total change in cents: ");
17.         totalCents = scanIn.nextInt();
18.
19.     halfDollars = totalCents / 50;
20.     remainder = totalCents % 50;
21.     quarters = remainder / 25;
22.     remainder = remainder % 25;
23.     dimes = remainder / 10;
24.     remainder = remainder % 10;
25.     nickels = remainder / 5;
26.     remainder = remainder % 5;
27.     pennies = remainder;
28.
29.
30.     System.out.println("\n\nThe change you entered in cents: " + totalCents +
31.         "\n\nHalf Dollars from change: " + halfDollars +
32.         "\nQuarters from change: " + quarters +
33.         "\nDimes from change: " + dimes +
34.         "\nNickels from change: " + nickels +
35.         "\nPennies remaining from change: " + pennies + "\n");
36.
37.     }//end main program
38. }//end of class
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top