1 import java.util.Scanner;
2
3 /**
4 This program prints the price per liter for a six-pack of cans.
5 */
6 public class Volume3
7 {
8 public static void main(String[] args)
9 {
10 // Read price per pack
11
12 Scanner in = new Scanner(System.in);
13
14 System.out.print("Please enter the price for a six-pack: ");
15 double packPrice = in.nextDouble();
16
17 // Compute pack volume
18
19 final double LITER_PER_OUNCE = 0.0296;
20 final double CAN_VOLUME = 12 * LITER_PER_OUNCE;
21 final double PACK_VOLUME = 6 * CAN_VOLUME;
22
23 // Compute and print price per liter
24
25 double pricePerLiter = packPrice / PACK_VOLUME;
26
27 System.out.printf("Price per liter: %8.2f", pricePerLiter);
28 System.out.println();
29 }
30 }