Pages

Friday, 1 April 2016

Chapter 2 Exercise 3, Introduction to Java Programming, Tenth Edition Y. Daniel LiangY.

(Convert feet into meters) Write a program that reads a number in feet, converts itto meters, and displays the result. One foot is 0.305 meter.

import java.util.Scanner;
public class Exercise_03 {

    public static void main(String[] Strings) {

        Scanner input = new Scanner(System.in);

        System.out.print("Enter a value for feet: ");
        double feet = input.nextDouble();
        double meters = feet * 0.305;
        System.out.println(feet + " feet is " + meters + " meters");

    }
}

No comments:

Post a Comment