new to java: homework question
hi everyone, i am new to programming and am having a really hard time on my homework assignment. we wrote a program in class that asks the user to input the number of *'s they want, and that number of *'s is printed. this is in a loop, and the question is continually asked until the user enters 'bye' .
on the hw, i was given a similar question: this program is supposed to read numbers from the keyboard, one at a time. every time a number is read, it is added to the sum of all numbers entered, which is then printed. the average of all the #'s entered should be calculated & printed. this also ends when the user enters 'bye' .
if anyone can point me in the right direction it would be really really helpful!
Code:
import java.util.*;
class SumofNums {
public static void main(String[] args) {
Scanner zip = new Scanner(System.in);
int number;
String input;
while(true) {
System.out.print("Enter a number: ");
input = zip.nextLine();
if (input.equalsIgnoreCase ("bye") ) {
break;
} else {
number = Integer.parseInt(input); //this is where i started having trouble.
while (number > 0) { //i'm not sure what to put in the while loop
System.out.print(number); //or how to keep track of the numbers entered.
number = number - 1;
}
System.out.println();
}
}
}