Jump to level 1
Convert totalOunces to gallons, pints, and ounces, finding the maximum number of gallons, then pints, then ounces.
Ex: If the input is 914, then the output is:
Gallons: 7
Pints: 1
Ounces: 2
Note: A gallon is 128 ounces. A pint is 16 ounces.
1 import java.util.Scanner;
2
3 public class MeasurementConverter {
4 public static void main(String[] args) {
5 Scanner scnr = new Scanner(System.in);
6 int totalOunces;
7 int numGallons;
8 int numPints;
9 int numOunces;
10
11 totalOunces = scnr.nextInt();
12
13 e3
14
15 System.out.println("Gallons: " + numGallons);
16 System.out.println("Pints: " + numPints);
17 System.out.println("Ounces: " + numOunces);
18 }