COMP2243 - Programming and Problem Solving

Syllabus Software Installation Assignments Tests
Lectures and Labs
**Back to Full Menu**

Fundamentals HelloWorld.java Basics.java Payroll.java Cartons.java Time.java DollarAmount.java StringPractice.java PayrollGUI.java



Cartons Program


Description

Cartons are used to store orange juice. A carton can store half gallon (1.89 liter) of juice, which is sold at retail price $2.99.

The purpose of this program is to input the quantity of juice produced in liter and the cost of producing one liter of juice, calculate the cartons needed to store orange juice and the profit, then print the result.

Associated Concepts:

Read data from input device: keyboard

Assign data to variables

Cast decimal value to integer

Print decimal values to certain decimal points

Algorithm:

Declare variables to store data items

Define constants to store constant values

Read data values from the keyboard and store them into variables

Calculate the result

Print the result with the decimal values formatted to certain decimal points.

Source Code



Sample Run



Video