Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started