Menu

[solved]-Hello Need Assistance Java Program Following Table Shows Approximate Speed Sound Air Water Q39029276

Hello, I need assistance with a Java program

The following table shows the approximate speed of sound in air,water, and steel.
Medium Speed
Air 1,100 feet per second
Water 4,900 feet per second
Steel 16,400 feet per second
Write a program that displays a menu allowing the user to selectair, water, or steel. After the user has made a selection, he orshe should ask to enter the distance a sound wave will travel inthe selected medium. The program will then display the amount oftime it will take.( round the answer to 4 decimal places).
Input validation: check that the user has selected one of theavailable choices from the menu. Do not accept distances less than0.

Below is what I have, but I am getting a syntax error on line32

// This program displays a menu allowing user to select air,water, or steel and the distance selected medium travels in soundwaves.

// Author: Autumn

import javax.swing.JOptionPane;

import java.text.DecimalFormat;

public class Homework2 {

public staticvoid main(String[] args) {

String userInputMedium;

double distance;

double time;

DecimalFormat formatter = newDecimalFormat(“##0.0000”);

JOptionPane.showInputDialog( “Please enter medium thatyou want the amount of time for: n “);

JOptionPane.showInputDialog( “Please enter air, water,or steel: “);

{

if (userInputMedium.equals(“air” ) ) {

time = (distance / 1100);

System.out.println(“The total timetraveled is ” + time + “.”);

} else if(userInputMedium.equals(“water” ) ) {

time = (distance / 4900);

System.out.println(“The total timetraveled is ” + time + “.”);

} else if(userInputMedium.equals(“steel” ) ) {

time = (distance / 16400);

System.out.println(“The total timetraveled is ” + time + “.”);

}

}

}

Error:

Exception in thread “main” java.lang.Error: Unresolvedcompilation problem:

Syntax error, insert “}” to complete ClassBody

Expert Answer


Answer to Hello, I need assistance with a Java program The following table shows the approximate speed of sound in air, water, and… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *