CSCI 161 - Lab 3: "Looper"

Objectives

The objectives of this assignment are to reinforce and help teach:

Overview

For this lab you will develop a program that will prompt the user for two different integer values and then display all the numbers between the first entered integer and the second entered integer, inclusively.

For example, if the user first enters 5 and then enters 12, the program will output the numbers: 5, 6, 7, ..., 11, 12

Take care for whether or not the first number entered by the user is less than or greater than the second number. For example, if the first number entered is 15 and the second numbered entered is 7, then the program should output the numbers: 15, 14, 13, ..., 8, 7. The order is important.

Your output should look just like the output format below, with each returned integer from your loop on its own line.

Instructions

Following are the instructions and you should follow them carefully:

  1. Using Eclipse create a new Java Project and name it: Lab3
  2. As with all your labs, add a class of the same name, Lab3, and include in that class a main method.
  3. Your program should be properly commented.
  4. Your program should use methods where appropriate. For example, your program needs to prompt for and get two different integer values; one it refers to as "first" and the other as "second". A proper method might be one that accepts as input the Scanner object and a string variable as to which integer is being requested ("first", or "second"). In that way, the method constructs the prompt text and prompts the user for the integer, reads it via the Scanner object, and returns it as an integer return.
  5. Your program should only output one (1) line of output if the first and second integers entered by the user are the same.
  6. Your program should output according to the "Output Format" below.
  7. When the lab is complete and working submit your Lab3.java file via AutoLab.

Output Format

Following is the desired output format:

        
        
Please enter the first integer:  15

Please enter the second integer:  7

Output:
15
14
13
12
11
10
9
8
7
        
        

Deadline

This lab must be AutoLab submitted to the instructor by 11:59pm on the Monday a week after it was assigned. Check AutoLab for the specific due date.