Part of the file's contents:
The 2 (this is 1 less than the number of following lines) is a count of the number of pairs of numbers that must be read in. You will need a loop to read the lines...
Type: Posts; User: Norm
Part of the file's contents:
The 2 (this is 1 less than the number of following lines) is a count of the number of pairs of numbers that must be read in. You will need a loop to read the lines...
Looks like you are making progress.
Does that code compile and execute and print out the correct values?
The next thing you need to do is use the value read into the number of changes to read in ...
Do one thing at a time. Read the first three+ lines and print them.
When that works, move on to doing the calculations.
Make a complete program, compile it and execute it.
Add some println statements to print out the values as I suggested in post #16
Why are you using an array named args? How does that get the data from the file?
The code in post #15 looks like it will read lines from a file. What happens when you use the Scanner methods...
Can you post the code for the reading the first two lines?
Explain what the problem is with reading the third line.
Are you asking how to write data to a text file?
What do you normally do with data that you read in from a file? How is this different?
I assume the two values to be compared are numeric.
To compare two numbers, use the <, >, ==, etc...
What are the formulas to do that? What steps does the program have to take?
That's strange. Earlier you said:
Can you explain?
You show that the data has three lines. Read each line,...
Do you know how to get the data from the file, if not please explain where the problems are.
Where do you get:
distance,
the speed
number of changes
Distance/speed = duration????
For...
Can you explain in English what data the program has to work with
and what the formulas are for doing the computations?
For example:
Start time + duration = arrival time
What is the data the program has available for making the computations?
What are the formulas for doing the computations?
The Scanner class has some easy to use methods for reading a text file.
The PrintWriter class could be used for writing to a text file.