Q:

(Convert feet into meters) Write a program that reads a number in feet, converts it to meters, and displays the result. One foot is 0.305 meter. Here is a sample run:

0

(Convert feet into meters) Write a program that reads a number in feet, converts it to meters, and displays the result. One foot is 0.305 meter. Here is a sample run:

Output:

Enter a value for feet: 16.5
16.5 feet is 5.0325 meters

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

/*
(Convert feet into meters) Write a program that reads a number in feet, converts it
to meters, and displays the result. One foot is 0.305 meter. Here is a sample run:
*/
import java.util.Scanner;

public class Exercise_02_03 {
	public static void main(String[] args) {
		// Create a Scanner object
		Scanner input = new Scanner(System.in);

		// Create constant value
		final double METERS_PER_FOOT = 0.305;

		// Prompt user to enter a number in feet
		System.out.print("Enter a value for feet: ");
		double feet = input.nextDouble();

		// Convert feet into meters
		double meters = feet * METERS_PER_FOOT;

		// Display results
		System.out.println(feet + " feet is " + meters + " meters");
	}
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now