ReversePrintII

ReversePrintII - items[counter = console.nextInt sum = sum...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//Program to read five numbers, find their sum, and //print the numbers in the reverse order. / import java.util.*; i public class ReversePrintII { static Scanner console = new Scanner(System.in); public static void main (String[] args) { int[] items = new int[5]; //declare an array item of //five components int sum; int counter; System.out.println("Enter five integers:"); sum = 0; for (counter = 0; counter < items.length; counter++)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { items[counter] = console.nextInt(); sum = sum + items[counter]; } System.out.println("The sum of the numbers = " + sum); System.out.print("The numbers in the reverse order are: "); //print the numbers in the reverse order for (counter = items.length - 1; counter >= 0; counter--) System.out.print(items[counter] + " "); System.out.println(); } }...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online