import java.io.*; import java.text.*; // //do while loop-a while loop is used when you need to execute the loop //at least once. The condition to exit is at the bottom. //This program also illustrates the use of a boolean to control a loop //and a function call (also called: invoking a 'method') public class program6 { static final double FACTOR=.39; public static void doCalculation() throws IOException { double inches, cm; System.out.println("Enter the value in inches: "); BufferedReader in =new BufferedReader (new InputStreamReader(System.in)); inches=Double.valueOf(in.readLine().trim()).doubleValue(); cm=inches*FACTOR; System.out.println(inches+" inches equals "+cm+ " centimeters.\n"); } public static void main(String[] args) throws IOException { boolean done=false; String choice; System.out.println("This program converts inches"+ " to centimeters.\n"); BufferedReader in =new BufferedReader (new InputStreamReader(System.in)); do { doCalculation(); System.out.println("Do you want to do another: " + "(y/n)?"); choice=in.readLine(); if (choice.equals("n")) done=true; } while(!done);//or: done==false System.out.println("\nProgram Over, Bye!!!\n"); } }