Posted: March 6th, 2014
The number of ounces for containers 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:
SIZE_1
SIZE_2
CLICK HERE TO GET THIS PAPER WRITTEN
import java.util.Scanner;
public class Liquid
{
public static void main(String[] args)
{
// Declare all named constants.
final int SIZE_1 = 40; // Container size 1 in ounces.
// Declare as a named constant the number of ounces in the
// second container.
// 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.
int totalOunces,
numSize1,
numSize2,
ouncesLeftOver;
// Prompt user for the total number of ounces to be shipped.
// [Insert code here]
// Read in the user’s input and store the information into a variable
// [Insert code here]
// Calculate the number of container 1, container 2, and left over
// ounces 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]
Place an order in 3 easy steps. Takes less than 5 mins.