Question

In: Computer Science

please right make it so that it can run on jGRASP and java code please thank...

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.

Solutions

Expert Solution

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...


Related Solutions

please write the java code so it can run on jGRASP Thanks! CODE 1 1 /**...
please write the java code so it can run on jGRASP Thanks! CODE 1 1 /** 2 * SameArray2.java 3 * @author Sherri Vaseashta4 * @version1 5 * @see 6 */ 7 import java.util.Scanner;8 public class SameArray29{ 10 public static void main(String[] args) 11 { 12 int[] array1 = {2, 4, 6, 8, 10}; 13 int[] array2 = new int[5]; //initializing array2 14 15 //copies the content of array1 and array2 16 for (int arrayCounter = 0; arrayCounter < 5;...
please write the java code so it can run on jGRASP Thanks! 1 /** 2 *...
please write the java code so it can run on jGRASP Thanks! 1 /** 2 * PassArray 3 * @Sherri Vaseashta 4 * @Version 1 5 * @see 6 */ 7 import java.util.Scanner; 8 9 /** 10 This program demonstrates passing an array 11 as an argument to a method 12 */13 14 public class PassArray 15 { 16 public static void main(String[] args) 17 { 18 19 final int ARRAY_SIZE = 4; //Size of the array 20 // Create...
Please convert This java Code to C# (.cs) Please make sure the code can run and...
Please convert This java Code to C# (.cs) Please make sure the code can run and show the output Thank you! Let me know if you need more information. Intructions For this assignment you will be creating two classes, an interface, and a driver program: Class Calculator will implement the interface CalcOps o As such it will implement hexToDec() - a method to convert from Hexadecimal to Decimal. Class HexCalc will inherit from Calculator. Interface CalcOps will have abstract methods...
Please I can get a flowchart and a pseudocode for this java code. Thank you //import...
Please I can get a flowchart and a pseudocode for this java code. Thank you //import the required classes import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class BirthdayReminder {       public static void main(String[] args) throws IOException {        // declare the required variables String sName = null; String names[] = new String[10]; String birthDates[] = new String[10]; int count = 0; boolean flag = false; // to read values from the console BufferedReader dataIn = new BufferedReader(new...
Question: Can I get the code in Java for this assignment to compare? Please and thank you....
Question: Can I get the code in Java for this assignment to compare? Please and thank you. Can I get the code in Java for this assignment to compare? Please and thank you. Description Write a Java program to read data from a text file (file name given on command line), process the text file by performing the following: Print the total number of words in the file. Print the total number of unique words (case sensitive) in the file. Print...
JAVA - PLEASE COMMENT CODE - THANK YOU: Implement a program that can input an expression...
JAVA - PLEASE COMMENT CODE - THANK YOU: Implement a program that can input an expression in postfix notation and output its value.
Please can I get a flowchart and pseudocode for this java code. Thank you. TestScore.java import...
Please can I get a flowchart and pseudocode for this java code. Thank you. TestScore.java import java.util.Scanner; ;//import Scanner to take input from user public class TestScore {    @SuppressWarnings("resource")    public static void main(String[] args) throws ScoreException {//main method may throw Score exception        int [] arr = new int [5]; //creating an integer array for student id        arr[0] = 20025; //assigning id for each student        arr[1] = 20026;        arr[2] = 20027;...
Please can I kindly get a flowchart for this java code. Thank you. //import the required...
Please can I kindly get a flowchart for this java code. Thank you. //import the required classes import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class BirthdayReminder {       public static void main(String[] args) throws IOException {        // declare the required variables String sName = null; String names[] = new String[10]; String birthDates[] = new String[10]; int count = 0; boolean flag = false; // to read values from the console BufferedReader dataIn = new BufferedReader(new InputStreamReader( System.in));...
Please take this c++ code and make it into java code. /* RecursionPuzzleSolver * ------------ *...
Please take this c++ code and make it into java code. /* RecursionPuzzleSolver * ------------ * This program takes a puzzle board and returns true if the * board is solvable and false otherwise * * Example: board 3 6 4 1 3 4 2 5 3 0 * The goal is to reach the 0. You can move the number of spaces of your * current position in either the positive / negative direction * Solution for this game...
JAVA programming language Modify the following code. Make changes so that Movies can be sorted by...
JAVA programming language Modify the following code. Make changes so that Movies can be sorted by title ----------------------------------------------------------------- package Model; import java.time.Duration; import java.time.LocalDate; import java.util.ArrayList; import java.util.List; // TODO - Modify the movie class so that Java knows how to compare two Movies for sorting by title public class Movie extends DataStoreObj { private String title; private String description; private LocalDate releaseDate; private Duration runningTime; private Rating rating; private List<Genre> genres = new ArrayList<>(); private List<Actor> actors = new...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT