
Hi There
I am here to learn and share some new and cool stuffs
Since I am a rookie I will start with a problem
I have this problem
When the program starts, you will be
asked to input an amount of numbers to for your calculations. This can be any number of
numbers. No matter what number you put in, it should ask you for that amount of numbers.
For instance, if you put in 100, you will be expected to put in 100 numbers. Once you put in the
total numbers for use, your program should ask you for each number, while displaying how
many numbers you have put in and how many you have left to go. At the end, the program
should be able to show you the Sum, Difference, Product, and the average of all your numbers
This is my code so far ( it doesn't give me the proper result)
package javaapplication13;
import java.util.Scanner;
public class JavaApplication13 {
/** Main method */
public static void main(String[] args) {
// Create a Scanner
Scanner input = new Scanner(System.in);
// Read an initial data
System.out.print( "Enter a number of numbers to use in your calculation ");
int data = input.nextInt();
// Keep reading data until the input equals number of numbers
int sum = 0;
while (data !=0) {
sum += data;
// Read the next data
System.out.print(
"You have entered 0 numbers you have 5 numbers left to enter ");
data = input.nextInt();
System.out.println("All numbers added together equal " + sum);
System.out.println("All numbers subtracted from each other equal " + sum);
System.out.println("All numbers multiplied6 together equal " + sum);
System.out.println("All numbers added together equal " + sum);
}
}
}

Re: Hi There
I hope you meant something like this:
int amountNums = Integer.parseInt(JOptionPane.showInputDialog("Ente r a number of numbers to use in your calculation "));
// Keep reading data until the input equals number of numbers
double add = 0.0;
double subtract = 0.0;
double multiplied = 1.0;
double average = 0.0;
for (int i = 1; i <= amountNums; i++) {
int number = Integer.parseInt(JOptionPane.showInputDialog("Numb er please:"));
add = add + number;
subtract = subtract  number;
multiplied = multiplied * number;
}
average = add / amountNums;
System.out.println("All numbers added together equal " + add);
System.out.println("All numbers subtracted from each other equal " + subtract);
System.out.println("All numbers multiplied together equal " + multiplied);
System.out.println("The average is: " + average);