Loops - /* @author: * Class: ITP 109 * Lab#: 5 * Date...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/* @author: * Class: ITP 109 * Lab#: 5 * Date modified: 02/17/2010 * Program description: This program will let us practice the use of 'switch' statements and different loops. * In the main menu, we will use 'switch' and 'while' loops. Then, we ask the program to read a list of integers * and determine the largest one. As for the factorial, the user will enter and integer and program will * calculate its factorial using 'for' loop. */ import java.util.Scanner; i public class Loops { p public static void main(String[] args) { p Scanner keyboard = new Scanner(System.in); S //declare all variables that will be used int factorial = 1, menu = 0, next=0, largestNum=0; boolean quit = false; b while (quit !=true) { System.out.println("Welcome to Lab5"); // This is the menu which the user will choose from System.out.println("Please enter one of the following choices:"); System.out.println(" 1 --> Largest Number"); System.out.println(" 2 --> Factorial"); System.out.println(" -1 --> Quit!"); menu = keyboard.nextInt();
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

Loops - /* @author: * Class: ITP 109 * Lab#: 5 * Date...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online