1 /**
2 This program computes the volume (in liters) of a six-pack of soda
3 cans and the total volume of a six-pack and a two-liter bottle.
4 */
5 public class Volume1
6 {
7 public static void main(String[] args)
8 {
9 int cansPerPack = 6;
10 final double CAN_VOLUME = 0.355; // Liters in a 12-ounce can
11 double totalVolume = cansPerPack * CAN_VOLUME;
12
13 System.out.print("A six-pack of 12-ounce cans contains ");
14 System.out.print(totalVolume);
15 System.out.println(" liters.");
16
17 final double BOTTLE_VOLUME = 2; // Two-liter bottle
18
19 totalVolume = totalVolume + BOTTLE_VOLUME;
20
21 System.out.print("A six-pack and a two-liter bottle contain ");
22 System.out.print(totalVolume);
23 System.out.println(" liters.");
24 }
25 }