Roxy Hasior

Greenhorn
+ Follow
since Mar 27, 2012
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Roxy Hasior

Yay! It works thanks. This is what I did:

10 years ago
Thanks for everyone's input. This was my first time posting on a programming forum.
So, it looks like in order to alert the scanner that the user is done inputting there must be some kind of signal (a non integer input).

For example adding a
boolean done = false;
while (!done)
{
...
}

I guess I was trying to avoid making the user input anything other than their numbers because this was the original question:

Write a program that prompts the user to a list of numbers, all on one line. If the list is empty, the program prints “No average”. Otherwise, the program then computes and prints the average of those numbers.

Sample run, with user input underlined:

Enter numbers: 10.5 7 -2.4
Average: 5.033333333333333

Write only one program class named Average with only a main method. Import any required class(es).
10 years ago
Hi, I'm new to programming and I'm studying for my test. I've come across this type of issue before and I've been able to get around it but I want to know how to actually fix it!
After the user inputs their list of numbers (separated by a whitespace) nothing happens... because while is in an infinite loop but I don't know how to break it (btw: we haven't learned "break" yet).
Thanks in advance for your help!


10 years ago