Final Answer:
java
import java.util.Scanner;
public class Yourlastname_Yourfirstname_midterm {
public static void main(String[] args) {
problem1();
}
public static void problem1() {
Scanner scanner = new Scanner(System.in);
int sum = 0;
int num;
System.out.println("Enter integers (0 to stop):");
while (true) {
num = scanner.nextInt();
if (num == 0) break;
if (num >= 10 && num <= 99) {
sum += num;
}
}
System.out.println("Sum of two-digit numbers: " + sum);
}
}
Step-by-step explanation:
The class "Yourlastname_Yourfirstname_midterm" contains a static method "problem1()" that uses a Scanner to continuously prompt the user for integer inputs until 0 is entered. Within the method, it accumulates the sum of only two-digit numbers entered by the user by checking if the input falls within the range of 10 to 99.
If a two-digit number is provided, it adds it to the running total. Once the user enters 0, indicating the end of input, the method returns the sum of all two-digit numbers entered. In the given test case scenario (1, 20, 300, 40, 5, 600, 0), the method correctly computes and returns the sum of the two-digit numbers (20 and 40), which equals 60.