Write a program that displays a table of meters starting at 0 and through some m
ID: 3767556 • Letter: W
Question
Write a program that displays a table of meters starting at 0 and through some maximum meter and their feet equivalents. you must write you program so maximum meter will be inputted via the scanner or JOptionPane class. Maximum meter can be different every time the user runs the program
2) Validation: Maximum meter cannot be less that 0 or a negative number.
3) the formula for converting meters into feet is : Feet = meter * 3.281
4) meters increase by 4 for every iteration
5) your program must use a loop to display the table in a text file. Format feet so the number have one decimal place. Meters may have one or no decimal places.
6) your output must be in formatted table
7) let the user know the data was written to your FEET.txt file
Example of what the table should look like in FEET.txt:
Meters Feet
-------------------------------------
0 0.0
4 13.1
8 26.2
12 39.4
16 52.5
etc... OR:
Meters Feet
-------------------------------------
0.0 0.0
4.0 13.1
8.0 26.2
12.0 39.4
16.0 52.5
etc....
Thanks in advance!
Explanation / Answer
import java.util.Scanner;
public class feetToMeters
{
public static void main (String [] args)
{
Scanner input = new Scanner (System.in);
System.out.println ("Enter a value for feet: ");
double value = input.nextDouble();
double meters = value/3.281;
System.out.println (value + " feet is " + meters + " meters ");
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.