Results 1 to 4 of 4
Thread: No Output (?)
- 02-09-2011, 04:45 PM #1
Member
- Join Date
- Oct 2010
- Posts
- 80
- Rep Power
- 0
No Output (?)
Hello All.
I am running this code in Eclipse. I enter a value (2) for newNum, but nothing else happens. Can someone tell me why? Thank you
Java Code:import java.util.*; public class Ex5_14 { static Scanner console = new Scanner(System.in); public static void main(String[] args) { int i; int newNum; int average; int sum; sum = 0; for (i = 0; i < 5; i++) { newNum = console.nextInt(); sum = sum + newNum; } average = sum / 5; System.out.println("The sum is " + sum); System.out.println("The average is " + average); } }
- 02-09-2011, 05:02 PM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,609
- Rep Power
- 5
What do you expect to happen? Step through the code one line at a time from the perspective of the computer...what will happen after you are prompted for and enter the first number?but nothing else happens
- 02-09-2011, 05:33 PM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,414
- Blog Entries
- 7
- Rep Power
- 17
- 02-09-2011, 05:42 PM #4
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,609
- Rep Power
- 5
Similar Threads
-
how to get the resultset output into an output file
By renu in forum New To JavaReplies: 0Last Post: 09-30-2010, 08:16 PM -
Why do I get this output?
By Allspark in forum New To JavaReplies: 3Last Post: 09-23-2010, 08:07 AM -
Need help with output
By cedric11 in forum New To JavaReplies: 4Last Post: 11-30-2009, 01:09 PM -
Can anyone tell me how this output?
By vysh in forum Advanced JavaReplies: 16Last Post: 05-10-2009, 08:32 PM -
Java, output string, getting correct output? HELP!
By computerboyo in forum New To JavaReplies: 2Last Post: 02-25-2009, 11:44 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks