Write a program that reads a number in feet, converts it to meters, and displays the result. One foot is 0.305 meter.
Note: Use datatype as Double
Input:
feet = 34.0
Output:
10.37 meters
import java.io.*; import java.util.*; public class temp{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); System.out.print("Feet: "); double a = sc.nextDouble(); double b = a * 0.305; System.out.println(String.format("%.3f",b)+" meters"); } }
INPUT_1:
Feet: 34.0
OUTPUT:
10.370 meters
INPUT_2:
Feet: 23.4
OUTPUT:
7.137 meters
INPUT_3:
Feet: 1
OUTPUT:
0.305 meters
INPUT_4:
Feet: 100
OUTPUT:
30.500 meters
INPUT_5:
Feet: 200
OUTPUT:
61.000 meters
ILLUSTRATION