Write a program to do the following:
· Use a for loop to sum all of the numbers between 1 and 50 that are divisible by 5.
· Use a while loop to sum all of the numbers between 1 and 50 that are divisible by 5.
Check that you are getting the answer you expected!
Hi im getting a compile error for my for loop and ive no idea where to start with the while loop can anybody could point me in the right direction for my while loop
class WS1Q2{ public static void main(String[] args){ int x, total= 0; for(x=1;x<=50;x++) { if(x / 5) { total = total + x; } } System.out.println("The total is "+total); }//close main }//close class