SHARE
TWEET

Untitled




Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- //Exam 1 - Problem 3
- //Jeffrey Davis
- import java.util.*;
- import java.text.*;
- public class exam1problem3
- {
- public static void main(String [] args)
- {
- Scanner scanIn = new Scanner(System.in);
- int totalCents, halfDollars, quarters, dimes, nickels, pennies, remainder;
- System.out.print("Enter your total change in cents: ");
- totalCents = scanIn.nextInt();
- halfDollars = totalCents / 50;
- remainder = totalCents % 50;
- quarters = remainder / 25;
- remainder = remainder % 25;
- dimes = remainder / 10;
- remainder = remainder % 10;
- nickels = remainder / 5;
- remainder = remainder % 5;
- pennies = remainder;
- System.out.println("\n\nThe change you entered in cents: " + totalCents +
- "\n\nHalf Dollars from change: " + halfDollars +
- "\nQuarters from change: " + quarters +
- "\nDimes from change: " + dimes +
- "\nNickels from change: " + nickels +
- "\nPennies remaining from change: " + pennies + "\n");
- }//end main program
- }//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.