# Hi There

• September 8th, 2012, 08:03 PM
Mjanja
Hi There
I am here to learn and share some new and cool stuffs

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);

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;

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);
}
}
}
• September 9th, 2012, 11:52 AM
Gavin Fraser
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 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:"));