// This is the solution to problem 4 of the sample question set + the improvization in class import java.util.Scanner; class Multiples { public static void main (String [] args) { int count; //counter variable int total=0; // variable to hold total. Should be initialized to 0. /* This loop counts from 0 through 200. If the current number happens to be divisible by 3, (remainder when divided by 3 =0), add to total.*/ for (count =0; count<=200; count++) { if(count % 3 == 0) total+= count; } System.out.println("The sum is : " + total); /* This is the imrovization we did in class. This program reads in user input. We keep accepting numbers until the user enters 0. We check if the number entered is a multiple of 3. If so, we add it to the total Scanner in = new Scanner (System.in); total =0; do { count = in.nextInt(); // read in the next number if (count % 3 == 0) // check if divisible by 3 total = total + count; // if yes, add to total }while(count != 0); // repeat until user entered 0. If we get 0, we exit the loop. System.out.println("The sum is : " + total); */ } }