Search:

Type: Posts; User: Norm

Search: Search took 0.12 seconds.

  1. Re: Read and write to a text file and calculate values

    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...
  2. Re: Read and write to a text file and calculate values

    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 ...
  3. Re: Read and write to a text file and calculate values

    Do one thing at a time. Read the first three+ lines and print them.
    When that works, move on to doing the calculations.
  4. Re: Read and write to a text file and calculate values

    Make a complete program, compile it and execute it.
    Add some println statements to print out the values as I suggested in post #16
  5. Re: Read and write to a text file and calculate values

    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...
  6. Re: Read and write to a text file and calculate values

    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?
  7. Re: Read and write to a text file and calculate values

    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...
  8. Re: Read and write to a text file and calculate values

    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,...
  9. Re: Read and write to a text file and calculate values

    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...
  10. Re: Read and write to a text file and calculate values

    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
  11. Re: Read and write to a text file and calculate values

    What is the data the program has available for making the computations?
    What are the formulas for doing the computations?
  12. Re: Read and write to a text file and calculate values

    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.
Results 1 to 12 of 12