Question
JAVA HELP. I need help with understanding why these errors are happening and what I need to do to fix them. It is really appreciated!
JAVA HELP. I need help with understanding why these errors are happening and what I need to do to fix them. It is really appreciated!
Here is my code:
import java.io.*; // I/O import java.util.*; // Scanner class
public class Lab1 { public static void main( String args[] ) { final double MILES_PER_MARATHON = 26.21875; // i.e 26 miles 285 yards
Scanner kbd = new Scanner (System.in);
// THE FOLLOWING THREE VARIABLES ARE PRINTED OUT AT THE END OF THE PROGRAM double aveMPH=0, aveMinsPerMile=0, aveSecsPerMile=0;
// YOUR JOB IS TO DO WHAT YOU HAVE TO TO TO PUT THE CORRECT VALUES INTO THEM // BEFORE THEY GET PRINTED OUT AT THE BOTTOM
System.out.print("Enter marathon time in hrs minutes seconds: "); // i.e. 3 49 37 // DO NOT WRITE OR MODIFY ANYTHING ABOVE THIS LINE int hour = kbd.nextInt(); int minute = kbd.nextInt(); int seconds = kbd.nextInt(); float toSeconds((minute * 60) + (hour * 3600) + seconds); aveMPH = ((MILES_PER_MARATHON/(toSeconds/3600)); float aveSecsPerMile = (toSeconds % 60.0); float aveMinsPerMile = (toSeconds/60.0);
// DO NOT WRITE OR MODIFY ANYTHING BELOW THIS LINE. JUST LET MY CODE PRINT THE VALUES YOU PUT INTO THE 3 VARS System.out.println(); System.out.format("Average MPH was: %.2f mph ", aveMPH ); System.out.format("Average mile split was %.0f mins %.1f seconds per mile", aveMinsPerMile, aveSecsPerMile ); System.out.println();
} // END MAIN METHOD } // EOF
Here is a sample output:
Lab1.java:23: error: ';' expected float toSeconds((minute * 60) + (hour * 3600) + seconds); Lab1.java:23: error: not a statement float toSeconds((minute * 60) + (hour * 3600) + seconds) Lab1.java:23: error: ';' expected float toSeconds((minute * 60) + (hour * 3600) + seconds); Lab1.java:23: error: not a statement float toSeconds((minute * 60) + (hour * 3600) + seconds); Lab1.java:23: error: ';' expected float toSeconds((minute * 60) + (hour * 3600) + seconds); Labi.java:23: error: not a statement float toSeconds((minute * 60) + (hour * 3600) + seconds); Lab1.java:23: error: ';' expected float toSeconds((minute * 60) + (hour * 3600) + seconds); Lab1.java:24: error: ')' expected aveMPH = ((MILES_PER_MARATHON/(toSeconds/3600)); 8 errors Ok. Command Prompt - X C:\Users\tim\Desktop\lab-01\solution>java Lab1 Enter marathon time in hrs minutes seconds: 28 44 Average MPH was: 12.22 mph Average_mile split was 4 mins 54.6 seconds per mile C:\Users\tim\Desktop\lab-01\solution>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