Summing apples and oranges from user input

Report a typo

Write a program that reads two integers from the user using Scanner, calculates their sum, and prints the result. The first input represents the number of apples, and the second input represents the number of oranges. The output should display the total number of fruits.

Sample Input 1:

5
3

Sample Output 1:

8

Sample Input 2:

10
7

Sample Output 2:

17
Write a program in Java 17
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
// Use a Scanner to read user input


// Read the number of apples from the user


// Read the number of oranges from the user


// Calculate the total number of fruits and print the result
System.out.println();
}
}
___

Create a free account to access the full topic