Professional Documents
Culture Documents
Name: _______________________
ACTIVITY: Study the following Java program.
import java.util.*;
public class ReversePrint
{
static Scanner console = new Scanner (System.in);
public static void main(String[ ] args)
{
int item0, item1, item2, item3, item4;
int sum;
System.out.println(“Enter five integers: “);
item0 = console.nextInt();
item1 = console.nextInt();
item2 = console.nextInt();
item3 = console.nextInt();
item4 = console.nextInt();
sum = item0 + item1 + item2 + item3 + item4;
System.out.println(“The sum of the numbers = “ + sum);
System.out.println(“The numbers in reverse order are: “);
System.out.println(item4 + “ “ + item3 + “ “ + item2 + “ “ + item1 + “ “ + item1 + “ “
+ item0;
}
}
Answer the following questions:
1. How many variables were used in the program?
2. What data types were used?
3. What was the program all about?
4. What is the output of the following code?
Name: _____________________________________
Name: _____________________________________
Name: ______________________________________