Click to See Complete Forum and Search --> : " I Need Helppppppp!!!


choice89
01-23-2005, 10:10 AM
Hello Webdeveloper,
I am a new memeber and I am asking for HELP! I am new to the programming world and I am taking a programming class that is kicking my BUTT!

I am trying to write a program that reads in a list int values, one per line, and outputs their sum as well as the numbers read in, with each number annotated to say what percentage it contributes to the sum. The dialog should look like this:

How many numbers will you enter?
4
Enter 4 integers, one per line:
2
1
1
2
The sum is 6.
the numbers are:
2 33.3333% of the sum.
1 16.6666% of the sum.
1 16.6666% of the sum.
2 33.3333% of the sum.

Could someone point me in the right direction I am pulling my HAIR Out!! This is what I have so far:


public class Homeworkone
{


public static void main(String[] args)

{
double[] numbers = new double[100];

int index;
double sum, average;
System.out.println("How many numbers will you enter?");
sum = 0;
for (index = 0; index < 100; index++)

}


}

Choice89

Erkki
01-25-2005, 12:02 PM
get the input from the user how many integer will be used.
open an array with the input you get from the user.
Then ask user to input inegers to sum.
You can use 3 "for loops": first get the integers user will enter, and put them into the array.
second, sum all the numbers in the array.
third, divide each numbers in the array to the sum and multiply by 100.
It is easy.
I don't know how you get inputs from the user, but i suggest you import cs1.Keyboard method.