• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



does anyone know what my problem is?/how to fix it?
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


it still does it
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
haha. alright, i know this is a noob question, but what do i change it to?
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 1849
15
Eclipse IDE Spring VI Editor Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
lol += is what i needed. i found it out.
 
Paper jam tastes about as you would expect. Try some on this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic