Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Specifications: The Chicago Cola Company wants to develop a program to track each delivery of cans of soft drinks. These are usually small deliveries. The

Specifications: The Chicago Cola Company wants to develop a program to track each delivery of cans of soft drinks. These are usually small deliveries. The program will read in one integer, the total number of cans of soft drink in a given order. Based on the given input value, the program will calculate and print the number of cases, the number of packs, and the number of remaining cans, or leftovers. At present, each case contains 24 cans and each pack contains 6 cans. These numbers could change at any time, so they must be named constants, not literal constants. Each named constant will be declared at the top of the program. Below that, each named constant is referred to only by its name. Call these two named constants: CANS_PER_CASE CANS_PER_PACK This program will help you understand how to do basic arithmetic operations in Java. You can calculate the number of cases, packs, and leftovers as follows: (1) number of cases = total number of cans divided by CANS_PER_CASE (an integer quotient) To get an integer quotient, use the / operator (see Chapter 2). (2) number of cans remaining after complete case have been removed, To get a remainder, use the % operator (see Chapter 2). (3) total number of packs = value from (2) above, divided by CANS_PER_PACK. To get a remainder, use the % operator (see Chapter 2). (4) total number of leftovers: the remainder from (3) above. Please follow the input/output formats shown below in the Sample Input and Sample Output sections. The output your program prints should be exactly the format shown below. Remember that the numbers given in the sample input/output are only examples. You need to write a program that works with any positive integer number. Later on in the course, we'll study how to check for bad input data, for example, negative numbers, unexpected strings, etc. For this assignment, you may assume that all numbers given to your program will be valid values, that is, positive integers. Sample Input #1: Please enter total number of cans to be shipped: 71 Sample Output #1: Chicago Cola Company Delivery Report Number of cans per case = 24 Number of cans per pack = 6 ==================================== Total number of cans: 71 Number of cases: 2 Number of packs: 3 Number of leftover cans: 5 Sample Input #2: Please enter total number of cans to be shipped: 99 Sample Output #2: Chicago Cola Company Delivery Report Number of cans per case = 24 Number of cans per pack = 6 ==================================== Total number of cans: 99 Number of cases: 4 Number of packs: 0 Number of leftover cans: 3 ===================================Code Outline:========================================= // Soda.java // Program descritption // Programming Assignment 2 // Fall 2017 // CS 1113 // Tine University // // [Type your name here.] // [Type your section here.] // [Type your description here.] import java.util.Scanner; public class Soda { public static void main(String[] args) { // Declare all named constants. final int CANS_PER_CASE = 24; //Number of cans in each case. // Declare as a named constant the maximum number of cans that a pack // can hold, which is currently 6. // This statement is similar to the "final int" statement above. // [Insert code here] // Declares the Scanner object to read in input. Scanner scan = new Scanner(System.in); // Declare all other variables that you will need. // Feel free to declare as many more variables as you need int totalCans, numCases, numCansRemainingAfterCases, numPacks, cansLeftOver; // Prompt the user for the total number of cans to be shipped. // This is a System.out.println statement. // [Insert code here] // Read in the user's input and store the information into a variable. // This statement will use scan.nextInt() and will assign the result // to the variable totalCans. // [Insert code here] Calculate the number of cases, remaining cans, packs, // and leftovers here. // [Insert code here] // Print out the results. // Write System.out.println statement(s) to print out the nine lines of // output that are required. // Do not calculate the values inside of the output statements. // The values to be printed should already be available in the variables // and named constants that were declared above. // [Insert code here] } // End of Main } // End of Soda.java 

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

Step: 3

blur-text-image

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 1 Lnai 9284

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Carlos Soares ,Joao Gama ,Alipio Jorge

1st Edition

3319235273, 978-3319235271

Students also viewed these Databases questions

Question

7. It is advisable to do favors for people whenever possible.

Answered: 1 week ago