Jumat, 01 April 2011
import java.io.*;
 
public class Conversion
{
static BufferedReader keyboard = new
BufferedReader(new InputStreamReader(System.in));
 
static final double CONVERSION = 2.54;
static final int INCHES_PER_FOOT = 12;
 
public static void main (String[] args) throws IOException
{
//declare variables
int feet;
int inches;
int totalInches;
double centimeter;
 
System.out.print("Enter feet: ");
System.out.flush();
feet = Integer.parseInt(keyboard.readLine());
System.out.println();
System.out.print("Enter inches: ");
System.out.flush();
inches = Integer.parseInt(keyboard.readLine());
System.out.println();
System.out.println("The numbers you entered are "
+ feet + " for feet " + "and "
+ inches + " for inches. ");
 
totalInches = INCHES_PER_FOOT * feet + inches;
 
System.out.println();
System.out.println("The total number of inches = "
+ totalInches);
 
centimeter = totalInches * CONVERSION;
 
System.out.println("The number of centimeters = "
+ centimeter);
 
}
}

0 komentar:

Posting Komentar

IKLAN

About Me

Total Tayangan Halaman

Diberdayakan oleh Blogger.

Entri Populer

Pengikut