/* * @topic T00200 Variables * @brief Sample Java program using data variables * * The program uses varialbles to print values. * It declare and assigns data to two variables, miles and gallons. * It also computes the miles-per-gallon value using division operator. */ public class VariablesDemo { public static void main(String[] args) { double miles; double gallons; miles = 202.5; gallons = 16.66; System.out.println("\nvalue of miles = " + miles + "\tvalue of gallons = " + gallons); double mpg = miles/gallons; System.out.println(); System.out.println(miles + " miles on " + gallons + " gallons = " + mpg +" mpg"); System.out.println(); } // end of main method } // end of class /* If you run the program, the output will look like this: value of miles = 202.5 value of gallons = 16.66 202.5 miles on 16.66 gallons = 12.154861944777911 mpg */