-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment1.java
More file actions
45 lines (39 loc) · 1.39 KB
/
Assignment1.java
File metadata and controls
45 lines (39 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package assignment1;
/*
Assignment 1
Jennifer Castano
*/
import java.util.Scanner;
public class Assignment1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int amount, originalChange, price, change,
quarters, dimes, nickels, pennies;
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter a whole number from 1 to 99. "
+ "That will be the price of the item in cents: ");
price = keyboard.nextInt();
System.out.print("Now enter in the amount of cents you will be paying with: ");
amount = keyboard.nextInt();
System.out.println("I will find a combination of coins");
System.out.print("that equals that amount of change: ");
System.out.println(amount - price);
change = amount - price;
originalChange = change;
quarters = change / 25;
change = change % 25;
dimes = change / 10;
change = change % 10;
nickels = change / 5;
change = change % 5;
pennies = change;
System.out.println(originalChange
+ " cents in coins can be given as:");
System.out.println(quarters + " quarters");
System.out.println(dimes + " dimes");
System.out.println(nickels + " nickels and");
System.out.println(pennies + " pennies");
}
}