Question: write a program in java to display how many cases are required to store boxes of cookies. Only use for loops, do, or do while.
write a program in java to display how many cases are required to store boxes of cookies. Only use for loops, do, or do while. A case of cookies holds 10 boxes of cookies. User will enter how many boxes of cookies that have been purchased. Print statements will include the number of boxes of cookies and also the number of cases required. Cannot use temporary storage places or any arrays. The last thing I don't understand how to do is to display the remainder as I cannot have a partially filled case.
import java.util.Scanner; public class CookieBoxes { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter number of boxes of cookies that have been purchased? "); int n = in.nextInt(); int numCases = 0; while (numCases*10 < n) { numCases++; } System.out.println("Number of boxes of cookies = " + n); System.out.println("Number of cases required = " + numCases); } } Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
