# Can someone help me figure out what to do with this Java code?

I am a beginner in Java and I would appreciate it if someone could help me figure out what to do with the rest of the code. I have already written some code but I can’t figure out the rest of the formulas. Can someone please help me?

Here are the instructions:

In the code below, type in three made up int grades and then sum and average them. Use casting to report the result as a double. For example, if the grades are 90, 100, and 94, the sum of the three numbers is 90 + 100 + 94 = 284, and the average is the sum 284 divided by 3 which casted to a double is 94.666667. You should use your variables instead of the numbers in your formulas. Type in three made up int grades and then sum and average them. Use type casting to report the result as a double.

Here is my code so far:

``````public class Challenge1_6
{
public static void main(String[] args)
{
// and initialize them to 3 values

// 2. Declare an int variable called sum for the sum of the grades
// 3. Declare a variable called average for the average of the grades
int average = sum / 3;
// 4. Write a formula to calculate the sum of the 3 grades (add them up).

// 5. Write a formula to calculate the average of the 3 grades from the sum using division and type casting.

// 6. Print out the average

}
}
``````

I don’t know java, but it seems that you’re initializing the variable sum, and you just need to declare it?

``````public class Challenge1_6
{
public static void main(String[] args)
{
// and initialize them to 3 values

// 2. Declare an int variable called sum for the sum of the grades
int sum;
// 3. Declare a variable called average for the average of the grades
int average;
// 4. Write a formula to calculate the sum of the 3 grades (add them up).