# Idiot requires help with simple java! PLEASE!

Hi java beginner here. I was hoping someone could help me understand what my teacher cant be bothered with. Got to create a simple program for class that will take random 5 numbers entered by user - check to see if any of those are divisible by 3 - add any numbers that are divisible by 3 and print a total.

please help me to understand what im doing. instruction was to create a LOOP with and IF statement. I cant quiet figure out how to gel all the pieces together so that it produces what I want below is what I have got. any help would be appreciated!!

``````
package javaapplication8;
import java.util.*;

public class JavaApplication8 {
public static void main(String[] args) {

System.out.println(" HI! Lets play a game... ");
System.out.println(" Pick any 5(five) numbers between 1 & 100: ");

Scanner s = new Scanner (System.in);
int n1; n1 = s.nextInt();
int n2; n2 = s.nextInt();
int n3; n3 = s.nextInt();
int n4; n4 = s.nextInt();
int n5; n5 = s.nextInt();
int count;
int total;

for (int x = 0 ; x <100; x+=3)
{
count = x++;
total = x+=3;

if (n1+=3){System.out.println(total);}
else {};

}

System.out.println(" There are " + count +"numbers divisivible by 3(three) ");

System.out.println(" The total of those numbers is: ");
}
}

``````

Seems like you should spend more time considering what your program needs to do.
If fitting pieces together is the issue then write the pieces first and then think about how they have to be fit together.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.