In: Computer Science
please right make it so that it can run on jGRASP and java code please thank you
Debug Problem 1:
As an intern for NASA, you have been instructed to debug a java program that calculates the speed that sound travels in water. Details about the formulas and correct results appear in the comments area at the top of the program
Here is the code to debug:
importjava.util.Scanner;
/**
This program demonstrates a solution to the
The Speed of Sound programming challenge.
With a distance of 100, the results will
display 0.02040816326530612 seconds
when debugged correctly.
The formula is distance / 4900
to calculate the speed of sound
when traveling through water
*/
publicclassTheSpeedOfSoundWater
{
publicstaticvoidmain(string[] args);
{
doubledistance = “
”; // Distance
// Create a Scanner object for
keyboard input.
Scanner keybaord =
newScanner(System.in);
// Get the distance.
System.out.print("Enter the distance
the sound wave will travel: ");
distance =
keyboard.next.Int();
// Calculate the time it will
take the wave to travel
// that distance in the
water
Systemout.printline("It will
take "+ (4900.0 / distance) " seconds.");
)
}
Submit the debugged TheSpeedOfSoundWater.java file in Canvas under the MidTermExam link.
import java.util.Scanner;
public class TheSpeedOfSoundWater
{
public static void main(String[] args)
{
double distance; // Distance
// Create a Scanner object for keyboard input.
Scanner keyboard = new Scanner(System.in);
// Get the distance.
System.out.print("Enter the distance the sound wave will travel:
");
distance = keyboard.nextDouble();
// Calculate the time it will take the wave to travel
// that distance in the water
System.out.println("It will take "+ (distance/4900.0)+"
seconds.");
}
}
Screenshot of the program with output :
NOTE: If you have any problem, please let me know through comments; I will surely revert back to you.
Please give a up vote .....
Thank you...