Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in java The below code produces the error message displayed below the code. 1. Explain what the error message is trying to tell you about

in java

The below code produces the error message displayed below the code.

1. Explain what the error message is trying to tell you about what is wrong with the code. (4 points)

2. Which line number does the Java compiler think the problem might be on? (2 points)

3. How might you fix this problem? (4 points)

 
  1. import java.util.Scanner;
  2. public class Question10 {
  3. public static void main(String[] args) {
  4. Scanner scnr = new Scanner(System.in);
  5. final double SPEED_OF_SOUND = 761.207; // Miles/hour (sea level)
  6. final double SECONDS_PER_HOUR = 3600.0; // Secs/hour
  7. final double secondsBetween = 0.0;
  8. double timeInHours;
  9. double distInMiles;
  10. System.out.println("Enter seconds between");
  11. System.out.print("lightning strike and thunder: ");
  12. secondsBetween = scnr.nextDouble();
  13. timeInHours = secondsBetween / SECONDS_PER_HOUR;
  14. distInMiles = SPEED_OF_SOUND * timeInHours;
  15. System.out.println("Lightning strike was approximately");
  16. System.out.println(distInMiles + " miles away.");
  17. }
  18. }

C:\Users\...\Question10.java:14: error: cannot assign a value to final variable secondsBetween

secondsBetween = scnr.nextDouble();

1 error

BUILD FAILED (total time: 0 seconds)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Factory Active Database For Enterprise Computing

Authors: Schur, Stephen

1st Edition

0471558443, 9780471558446

Students also viewed these Databases questions

Question

prove without using induction e) n!=O(nn)

Answered: 1 week ago

Question

how would you have done things differently?

Answered: 1 week ago

Question

3. What information do participants need?

Answered: 1 week ago