Search:

Type: Posts; User: hoobahstank

Search: Search took 0.36 seconds.

  1. Replies
    47
    Views
    4,265

    Re: Java read in + print to a file

    Done some reworking and got this now


    while (inputScanner.hasNextLine())

    {

    String Name, isCov;
    int quantity;
    double combinedCost,cost, amountCov, amountDue, pctCovered;
  2. Replies
    47
    Views
    4,265

    Re: Java read in + print to a file

    With this code my program goes through the whole file but i still did not the format properly, but how would i add the the 2nd and 3rd i values?


    while (inputScanner.hasNextLine())

    {...
  3. Replies
    47
    Views
    4,265

    Re: Java read in + print to a file

    Is there any other way to do it? Like a more simple way? Only because the professor hasn't mentioned a counter to be needed at all.
  4. Replies
    47
    Views
    4,265

    Re: Java read in + print to a file

    Every line is not a number though, it is like every 6th line is a number i need to keep a total of, do i need to make an exception in the loop so that every like 6th line i hold that value?
  5. Replies
    47
    Views
    4,265

    Re: Java read in + print to a file

    question, i have to add totals of some numbers in the loop, am i able to do this within a loop or is there like a class or function or something i need to add to code?
  6. Replies
    47
    Views
    4,265

    Re: Java read in + print to a file

    So my code is coming along well. Its not the prettiest but it works. Except for formatting the output. Each column is not the same distance away so how can i make it so each output fits under the...
  7. Replies
    47
    Views
    4,265

    Re: Java read in + print to a file

    OK back after a couple days, i have simplified my code, this currently works to an extent. My professor today gave us pseudocode on how we should write this program. It went:
    Open input file
    Open...
  8. Replies
    47
    Views
    4,265

    Re: Java read in + print to a file

    This is currently what the output looks like.


    Pet Vet Visit Report
    Vet: Andrea Rodriguez
    Date: Andrea Rodriguez/Andrea Rodriguez/Andrea RodriguezPet Vet Visit Report
    Vet: 9
    Date: 9/9/9Pet...
  9. Replies
    47
    Views
    4,265

    Re: Java read in + print to a file

    Yea i just put in a print statement and it is correctly reading the file, so my issue is with how i can output it nicely.

    --- Update ---

    This is what i got now, but this prints these 3 lines...
  10. Replies
    47
    Views
    4,265

    Re: Java read in + print to a file

    So i can create the printstream outside of the loop but the output also cant be in the loop, so would it go before or after the loop? Since this continually outputs vet: then whatever is read.

    ...
  11. Replies
    47
    Views
    4,265

    Re: Java read in + print to a file

    Hey so i now am outputting into the file but im not getting the data to transfer over. The only output i get is vet: Is this because im printing after the loop reads through the whole file?

    ...
  12. Replies
    47
    Views
    4,265

    Re: Java read in + print to a file

    Found my issue. That line was incorrect on my program i had = new Scanner(fileName) i did not have the new file and extra set of parentheses.
  13. Replies
    47
    Views
    4,265

    Re: Java read in + print to a file

    It made no difference. I went back to this code and it just outputs the filename back to me still.


    while (inputScanner.hasNextLine())

    {
    String i = inputScanner.nextLine();...
  14. Replies
    47
    Views
    4,265

    Re: Java read in + print to a file

    File name has to be the path? I have just been inputting the name of the file which is in the same folder. Is that wrong?
  15. Replies
    47
    Views
    4,265

    Re: Java read in + print to a file

    Nothing. Im startin to think maybe i dont have the file in the correct spot. The file has to be in the folder with all the other code right? I put it in the same folder but unsure if it has to go to...
  16. Replies
    47
    Views
    4,265

    Re: Java read in + print to a file

    OK so i switched it up and here is the code. But after i enter the file names it just ends for some reason.


    try
    {

    Scanner inputScanner = new Scanner(new File(fileName));
    ...
  17. Replies
    47
    Views
    4,265

    Re: Java read in + print to a file

    Kinda confused, so i used a wrong kind of scanner?
  18. Replies
    47
    Views
    4,265

    Re: Java read in + print to a file

    I made a catch statement and it now runs. But the output is just one line and its the name of the file that i input.


    try
    {

    Scanner inputScanner = new Scanner(fileName);
    ...
  19. Replies
    47
    Views
    4,265

    Re: Java read in + print to a file

    Right, i do not know how to structure the loop file. I have this:


    try
    {

    Scanner inputScanner = new Scanner(fileName);

    while (inputScanner.hasNextLine())
  20. Replies
    47
    Views
    4,265

    Re: Java read in + print to a file

    That would work yes.
  21. Replies
    47
    Views
    4,265

    Re: Java read in + print to a file

    No each line has a single item of data. Either a string or int, it is a set format so i will know when it is a string and when it is a int. Also i know i need to have a scanner to read in the file...
  22. Replies
    47
    Views
    4,265

    Re: Java read in + print to a file

    The file contains information from a vet office so it holds like a name then the next line is age and procedure, amount. Theres a whole list i have its about 10 different things. I need to read in...
  23. Replies
    47
    Views
    4,265

    Java read in + print to a file

    Need to read in from a file. That file is a list of information like a name then next line can be a number. I need to take that info a output it into a file. So here i have the code to get the two...
Results 1 to 23 of 23