CSCI 161 - Lab 4: "Number Wizard"

Objectives

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

Overview

In this lab you will develop a program that is playfully called the "Number Wizard." The Number Wizard is named such because it can look at a series of integers entered and then astound you and your friends by providing interesting insights into the integer series.

To help you sharpen your text output formatting skills, the output of the program is purposfully "chatty", taking on a persona of sorts.

Your program will ask the user how many integers are in the series (any positive number is allowed for that, ask again if the user enters a negative or 0) and then ask the user to enter the integers that make up the number series, one at a time, until the program has asked for all the integers in the series.

Lastly, your program will print out statistics about the integer series including:

Instructions

Following are the instructions and you should follow them carefully:

  1. Using Eclipse create a new Java Project and name it: Lab4
  2. As with all your labs, add a class of the same name, Lab4, and include in that class a main method.
  3. Your program should be properly commented, indented and use whitespace appropriately.
  4. It is acceptable and encouraged that your program use public class variables for holding the "statistics" related to the series (min, max, total, ...).
  5. Your program should employ class constants where appropriate. Two very useful constants that you may wish to utilize are:
                
    	public static final int MAX_INT = Integer.MAX_VALUE;
    	public static final int MIN_INT = Integer.MIN_VALUE;            
                
                
  6. When outputting your program should only use System.out.printf (not print nor println) so that you gain familiarity with using a more flexible function for more advanced formatting needs.
  7. Your program should use your own, additional methods to reduce the code complexity and length of the main method. Your additional methods should start with verbs and having meaningful names such as (your names may vary): displayIntro, getNextInteger, printStatistics, etc.
  8. Your program should output according to the "Output Specification" below.
  9. Your program must work with redirected input as well as input from the user. Test both.
  10. Note that your program will be graded according to the following rubric.
  11. When the lab is complete and working submit your Lab4.java file via AutoLab.

Output Specification

Following is the desired output format:

 
Greetings!

I am the "Number Wizard" and I will astound you with my ability
to analyze an integer series.

How many integers are in your series?  15
	Your integer # 1 is?  22
	Your integer # 2 is?  18
	Your integer # 3 is?  4
	Your integer # 4 is?  17
	Your integer # 5 is?  3
	Your integer # 6 is?  3
	Your integer # 7 is?  3
	Your integer # 8 is?  19
	Your integer # 9 is?  -8
	Your integer # 10 is?  0
	Your integer # 11 is?  4
	Your integer # 12 is?  4
	Your integer # 13 is?  4
	Your integer # 14 is?  4
	Your integer # 15 is?  12

Thank you for your 15 entries.

The "Number Wizard" has reviewed your series and conjured the
following:

	Maximum integer in series.................22
	Minimum integer in series.................-8
	Number of 0s in series....................1
	Number of even integers in series.........10
	Number of odd integers in series..........5
	Average of all integers in series.........7.27
	Total of all integers in series...........109     

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.