Search:

Type: Posts; User: javaman1

Page 1 of 3 1 2 3

Search: Search took 0.23 seconds.

  1. Replies
    46
    Views
    3,807

    Re: Spaceship question...

    i think the for loop increments to store the next value in the array. But my time is up anyway. Submitted 5 mins ago. :/
  2. Replies
    46
    Views
    3,807

    Re: Spaceship question...

    yea i mis read when u said to place it outside the loop.
    this is what it prints
    --------------------Configuration: <Default>--------------------
    an ID [1280, 1280, 1280, 1280, 1280, 1280, 1280,...
  3. Replies
    46
    Views
    3,807

    Re: Spaceship question...

    this is what it printed
    --------------------Configuration: <Default>--------------------
    %d [1280, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    %d [1280, 1280, 0, 0, 0, 0, 0, 0, 0, 0]
    %d [1280, 1280, 1280, 0, 0,...
  4. Replies
    46
    Views
    3,807

    Re: Spaceship question...

    yea i saw the posts but that does not tell me anything. How is the logic incorrect?where? how do i changed the logic?
  5. Replies
    46
    Views
    3,807

    Re: Spaceship question...

    import java.util.*;
    import java.io.*;
    public class Spaceship{
    public static void main(String[]args)throws IOException{
    Scanner in = new Scanner(new FileReader("distances.txt"));
    int []...
  6. Replies
    46
    Views
    3,807

    Re: Spaceship question...

    ok now its just printing the last number from the file 10 times


    int [] distance = new int [10];//array of size 10
    int dist=in.nextInt();//read first value from file
    int i;
    while...
  7. Replies
    46
    Views
    3,807

    Re: Spaceship question...

    i did that but when i run the program im getting this:

    --------------------Configuration: <Default>--------------------
    Exception in thread "main" java.util.NoSuchElementException
    at...
  8. Replies
    46
    Views
    3,807

    Re: Spaceship question...

    1.read value from file
    2.store in array.

    i did that but its not working
  9. Replies
    46
    Views
    3,807

    Re: Spaceship question...

    ok but how. I dont see where im getting the error. and i placed println all over. which line do i have to change?
  10. Replies
    46
    Views
    3,807

    Re: Spaceship question...

    ut my code is reading data from the file. but why is it only displaying the same value?
  11. Replies
    46
    Views
    3,807

    Re: Spaceship question...

    yea this is what i got--------------------Configuration: <Default>--------------------
    1280
    1280
    1280
    1280
    1280
    1280
    1280
    1280
    1280
  12. Replies
    46
    Views
    3,807

    Re: Spaceship question...

    i read the values into the array but its displaying each value 4 times. thats my only problem
  13. Replies
    46
    Views
    3,807

    Re: Spaceship question...

    I want to store all the values from the text file into the array.
  14. Replies
    46
    Views
    3,807

    Re: Spaceship question...

    int [] distance = new int [10];//array of size 10
    int dist=in.nextInt();//read first value from file

    while (dist!=0){//while value is not equal to 0 do

    for(int...
  15. Replies
    46
    Views
    3,807

    Re: Spaceship question...

    ok i made some changes and now the program is reading all the values but it is displaying each value 4 times.ow can i fix it so that it only displays each value once?


    int [] distance = new int...
  16. Replies
    46
    Views
    3,807

    Re: Spaceship question...

    ok i added some printlsn and i made some progress. not too sure how to format the code like you said.

    but the program is now reading all the data and displaying it. however after it is displayed...
  17. Replies
    46
    Views
    3,807

    Re: Spaceship question...

    the file im reading from consists of several integers. the last value is zero. so im trying to read the values. zero is the end of file value so i must stop reading the data when a zero is encountered
  18. Replies
    46
    Views
    3,807

    Re: Spaceship question...

    public static void main (String [] args) throws IOException{
    Scanner in = new Scanner(new FileReader("distances.txt"));

    int [] distance = new int [100];
    int dist=in.nextInt();

    while...
  19. Replies
    46
    Views
    3,807

    Re: Spaceship question...

    this is what i tried but its only displaying the same number.



    public static void main (String [] args) throws IOException{
    Scanner in = new Scanner(new FileReader("distances.txt"));
    ...
  20. Replies
    46
    Views
    3,807

    Re: Spaceship question...

    I dont know what is an array list. We just did basic arrays in class so i dont think i can use that.
  21. Replies
    46
    Views
    3,807

    Re: Spaceship question...

    yes the numbers represent fueling stations from Earth to the destination. Is there a way to read those values into an array without knowing the size of the array

    --- Update ---



    this does...
  22. Replies
    46
    Views
    3,807

    Spaceship question...

    A spaceship has to travel a distance of 1500 miles away from earth. The spaceship can only travel 220 miles before it needs to refuel. It is fueled before it leaves earth and there are several...
  23. Replies
    43
    Views
    2,219

    Re: Count out program-- How do i do this?

    had to submit it already. We can use those Array.toString yet since the lecturer did not teach it and does not want us implementing things he did not teach.
  24. Replies
    43
    Views
    2,219

    Re: Count out program-- How do i do this?

    lol.What do i have to do to make post #4 work?
  25. Replies
    43
    Views
    2,219

    Re: Count out program-- How do i do this?

    is this close? im getting an infinite loop then my program crashed.


    System.out.printf("Enter a number:");
    int n = in.nextInt();
    System.out.printf("Enter a value for m:");
    int m =...
Results 1 to 25 of 65
Page 1 of 3 1 2 3