Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Allan;
- public class Coins {
- int cents = 19; //Set this to anything you want
- //Print these out at the end
- int quarters;
- int dimes;
- int nickels;
- int pennies;
- //Constructor
- public Coins() {
- quarters = cents / 25;
- cents = cents % 25;
- dimes = cents / 10;
- cents = cents % 10;
- nickels = cents / 5;
- cents = cents % 5;
- pennies = cents;
- print ();
- }
- private void print () {
- System.out.println("Quarters = "+ quarters +" ");
- System.out.println("Dimes = "+ dimes +" ");
- System.out.println("Nickels = "+ nickels +" ");
- System.out.println("Pennies = "+ pennies +" ");
- }
- public static void main(String[] args) {
- Coins coins = new Coins();
- }
- }
Add Comment
Please, Sign In to add comment