Answered step by step
Verified Expert Solution
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)
- import java.util.Scanner;
- public class Question10 {
- public static void main(String[] args) {
- Scanner scnr = new Scanner(System.in);
- final double SPEED_OF_SOUND = 761.207; // Miles/hour (sea level)
- final double SECONDS_PER_HOUR = 3600.0; // Secs/hour
- final double secondsBetween = 0.0;
- double timeInHours;
- double distInMiles;
- System.out.println("Enter seconds between");
- System.out.print("lightning strike and thunder: ");
- secondsBetween = scnr.nextDouble();
- timeInHours = secondsBetween / SECONDS_PER_HOUR;
- distInMiles = SPEED_OF_SOUND * timeInHours;
- System.out.println("Lightning strike was approximately");
- System.out.println(distInMiles + " miles away.");
- }
- }
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started