ReversePrintII

ReversePrintII - { items[counter] = console.nextInt(); 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(&quot;The sum of the numbers = &quot; + sum); System.out.print(&quot;The numbers in the reverse order are: &quot;); //print the numbers in the reverse order for (counter = items.length - 1; counter &gt;= 0; counter--) System.out.print(items[counter] + &quot; &quot;); System.out.println(); } }...
View Full Document

Ask a homework question - tutors are online