Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PC Magazine Guide To Client Server Databases

Authors: Joe Salemi

1st Edition

156276070X, 978-1562760700

More Books

Students also viewed these Databases questions

Question

Are we maintaining too much redundant information?

Answered: 1 week ago