Site Navigation

Site Search

CS 110: Program 6 main content

Student Learning Objectives

Program 6 Assignment

Program 6 is based on Chapter 5, Programming Challenge Exercise 8 of your textbook.

Write a program, BigAndSmall.java, with a loop that lets the user enter a series of double numbers. The user should enter 0 to signal the end of the numbers.

After the user has entered all the numbers, the program should display the largest number, the smallest number, and the mean (average) of the numbers entered.

Note: Program 6 needs only one Java class file, BigAndSmall.java, which contains a main method. You do not need to use a separate class file.

Boundary Conditions

There are three different conditions you need to consider with this program.

  1. Normal case: two or more double values entered by the user
  2. One number: the user enters only one double number as input
    • Make that value entered both the largest, the smallest, and the mean values
  3. No values: the user immediately enters 0 as the signal to quit
    • Output the string "You did not enter any numbers"

Sample Sessions

Sample Session: Normal Case

Enter a number or 0 to quit: 50.5
Enter a number or 0 to quit: 22.2
Enter a number or 0 to quit: 30.3
Enter a number or 0 to quit: 100.0
Enter a number or 0 to quit: 0
Largest: 100.0
Smallest: 22.2
Mean: 50.75

Sample Session: One number entered

Enter a number or 0 to quit: 5.5
Enter a number or 0 to quit: 0
Largest: 5.5
Smallest: 5.5
Mean: 5.5

Sample Session: No numbers entered

Enter a number or 0 to quit: 0
You did not enter any numbers

What to turn in at the start of the next lab

File Header Comment

Include a file header comment at the top of every source code file. Include the assignment number, your cs110 account number, your name, completion time, and the honor code.

Remember, program assignments are to be done on your own. If you receive help understanding or debugging the assignment, you must acknowledge the person who helped. You must do the coding on your own.

//**********************************************************
// Assignment: Program 6
// Account: (Enter your cs110 account number here)
//
// Author: (Enter your full name here)
//
// Completion time: (Enter the total number of hours you
//                   spent on the assignment)
//
// Honor Code: I pledge that this program represents my own
//   program code. I received help from (enter the names of
//   others that helped with the assignment, write no one if
//   you received no help) in understanding and debugging my program.
//*********************************************************

Grading Criteria

20 points possible
CS 110 Program 6 Grading Sheet (PDF)