Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I will give good reviews; if the program comes up exactly as it does below the output specification, THANK YOU CSCI 161 - Lab 4:

I will give good reviews; if the program comes up exactly as it does below the output specification, THANK YOU

CSCI 161 - Lab 4: "Number Wizard"

Objectives

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

proper Java program class construction, purpose of the main method and use of other methods that each perform a smaller part of the overall problem

use of class variables and class constants

use of methods to reduce main method complexity

use of conditional statements (if/else)

use of for loops, in particular a cumulative algorithm loop

use of Scanner class for integer input

use of the Integer class and useful constants

text formatting

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:

maximum in the series

minimum in the series

number of times 0 occured in the series

number of even integers in the series

number of odd integers in the series

average of all integers in the series

total of all integers in the series

Instructions

Following are the instructions and you should follow them carefully:

Using Eclipse create a new Java Project and name it: Lab4

As with all your labs, add a class of the same name, Lab4, and include in that class a main method.

Your program should be properly commented, indented and use whitespace appropriately.

It is acceptable and encouraged that your program use public class variables for holding the "statistics" related to the series (min, max, total, ...).

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; 

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.

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.

Your program should output according to the "Output Specification" below.

Your program must work with redirected input as well as input from the user. Test both.

Note that your program will be graded according to the following rubric.

When the lab is complete and working submit it as Lab4

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 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Carlos Coronel, Steven Morris

14th Edition

978-0357673034

More Books

Students also viewed these Databases questions