- 2
2.11.2: Compute change.
A cashier distributes change using the maximum number of five dollar bills, followed by one dollar bills. For example, 19 yields 3 fives and 4 ones. Write a single statement that assigns the number of one dollar bills to variable numOnes, given amountToChange. Hint: Use the % operator.
3 odpowiedzi
+ 1
Take a look at https://code.sololearn.com/cGhjdglNjbAp
0
import java.util.Scanner;
public class ComputingChange {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int amountToChange;
int numFives;
int numOnes;
amountToChange = scnr.nextInt();
numFives = amountToChange / 5;
/*Your solution goes here */
System.out.print("numFives: ");
System.out.println(numFives);
System.out.print("numOnes: ");
System.out.println(numOnes);
}
}
0
Sandra M.
Hi, if you want to post a coding problem- be it a challenge for others, or assistance, you might want to post them here:
https://www.sololearn.com/Discuss/1270852/?ref=app
This thread is a collection of coding problems from our users, feel free to check it out.
Don’t forget to star the thread so you can receive updates whenever there’s a new post!