• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

when i run my virtual machine just keeps going, but no output.

 
nathan gibson
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



does anyone know what my problem is?/how to fix it?
 
Henry Wong
author
Marshal
Pie
Posts: 21192
81
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when i run my virtual machine just keeps going, but no output.


Well, to have output, you actually need to generate output. Your code doesn't seem to do that. In fact, it doesn't even prompt the user when taking input -- it just fetches the input.

My guess is that your program is stuck waiting for more input from the user...

Henry
 
Paul Clapham
Sheriff
Posts: 21117
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your problem is that you don't have enough lines of code which produce output. Add some more of them and you'll be able to see what your program is doing and thus figure out how to change it. Example of code you should add:
 
nathan gibson
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


it still does it
 
Henry Wong
author
Marshal
Pie
Posts: 21192
81
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As already mentioned... My guess is that your program is stuck waiting for more input from the user. You have an infinite loop waiting for input.

Or are you now saying that you removed all that stuff?

Henry
 
nathan gibson
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:As already mentioned... My guess is that your program is stuck waiting for more input from the user. You have an infinite loop waiting for input.

Or are you now saying that you removed all that stuff?

Henry

it doesnt ask for user input, does it? if it does please point out my error.
 
Henry Wong
author
Marshal
Pie
Posts: 21192
81
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post the complete code? I can't tell what you are doing.

[EDIT: never mind. can you post the complete code? I am totally confused at the moment.]

Henry
 
nathan gibson
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:Can you post the complete code? I can't tell what you are doing.

[EDIT: never mind. can you post the complete code? I am totally confused at the moment.]

Henry


i changed it to == and it still did the same thing. do you know anything else it could be?
 
nathan gibson
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:Can you post the complete code? I can't tell what you are doing.

[EDIT: never mind. can you post the complete code? I am totally confused at the moment.]

Henry

 
Henry Wong
author
Marshal
Pie
Posts: 21192
81
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nathan gibson wrote:
it doesnt ask for user input, does it? if it does please point out my error.


I knew I wasn't going crazy. I swore I saw it... it asks for user input here...



The "in" variable is a scanner object that is reading from System.in, hence, the code is waiting here for the user to type in an integer.

Henry
 
nathan gibson
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
haha. alright, i know this is a noob question, but what do i change it to?
 
Henry Wong
author
Marshal
Pie
Posts: 21192
81
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nathan gibson wrote:haha. alright, i know this is a noob question, but what do i change it to?


It's your program. If you don't know what is it supposed to do, how do you expect us to know?

Henry
 
nathan gibson
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:
nathan gibson wrote:haha. alright, i know this is a noob question, but what do i change it to?


It's your program. If you don't know what is it supposed to do, how do you expect us to know?

Henry


im sorry, its just im very close to finishing this. i have been working on it for days. thank you for your patience.
i have updated my code to this:

it will run now, but i cant get my output to work correctly. i think my problem is that i dont know how to calculate the sum of the numbers, can you show me?
 
nathan gibson
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i got it this far. now it is def the way i am doing my sum. i get a number for sum, just not correct.
 
Janeice DelVecchio
Saloon Keeper
Posts: 1809
12
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
while (inFile.hasNextInt())
{
data = inFile.next( );
num = inFile.nextInt ();
// try putting a System.out.println(num); here
sum = + num;
// and a System.out.println(sum + " " + num); here......... this way you might be able to see why it's not coming out right......

}



My $0.02,
Janeice
 
nathan gibson
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lol += is what i needed. i found it out.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic