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: ");
}
}