Lab 03

A Below Average Winter

 

Objective:

 

Write a program that takes in temperatures for 10 days and stores it in an array.  Find the average temperature for those 10 days, and then print the number of days and the temperatures that were strictly below the average.

 

Lab Solution

 

Requirements:

 

 

Example Dialog:

 

Welcome to the below average temperature tester program.

 

Please enter the temperature for day 1

33.0

Please enter the temperature for day 2

20.0

Please enter the temperature for day 3

41.0

Please enter the temperature for day 4

48.0

Please enter the temperature for day 5

60.0

Please enter the temperature for day 6

51.0

Please enter the temperature for day 7

29.0

Please enter the temperature for day 8

71.0

Please enter the temperature for day 9

63.0

Please enter the temperature for day 10

66.0

 

The average temperature was 48.2

The days that were below average were

Day 1 with 33.0

Day 2 with 20.0

Day 3 with 41.0

Day 4 with 48.0

Day 7 with 29.0

 

 

Solution Tests:

  1. Is your name written as a comment in all source files?
  2. Does the solution compile (no syntax errors)?
  3. Given the input <33.0, 20.0, 41.0, 48.0, 60.0, 51.0, 29.0 71.0, 63.0, 66.0> does the program print out:
    The average temperature was 48.2

The days that were below average were

Day 1 with 33.0

Day 2 with 20.0

Day 3 with 41.0

Day 4 with 48.0

Day 7 with 29.0

  1. Given the input <10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0> does the program print out:
    The average temperature was 55.0

The days that were below average were

Day 1 with 10.0

Day 2 with 20.0

Day 3 with 30.0

Day 4 with 40.0

Day 5 with 50.0

  1. Given the input <10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0> does the program print out:
    The average temperature was 10.0

The days that were below average were

 

Lab Report

  1. Create a section named “Problem” and describe this lab’s problem in your own words. (10pts).
  2. Create a section named “Solution Description” and describe how the code solves the problem in your own words. (10pts).
  3. Create a section named “Problems Encountered” and describe the various syntax, run-time, and logic errors that were encountered while implementing the solution. (10pts).
  4. Draw a flow chart to solve this problem in the proposed solution section.
  5. Are arrays able to change size as in grow or shrink length?
  6. What is the last valid index in an array with a given length?
  7. Given the following code snippet, are there any kind of errors? If so, name the types, where, and how this code can be fixed. Otherwise, what does this code print to the console?

 

 

  1. Given the following code snippet, are there any kind of errors? If so, name the types, where, and how this code can be fixed. Otherwise, what does this code print to the console?

 

 

  1. Given the following code snippet, are there any kind of errors? If so, name the types, where, and how this code can be fixed. Otherwise, what does this code print to the console?

 

 

  1. Given the following code snippet, are there any kind of errors? If so, name the types, where, and how this code can be fixed. Otherwise, what does this code print to the console?

 

 

Finally:

Upload the source code (.JAVA File Extension) and written lab report (.DOC, .DOCX, or .PDF file extension) to the CSCE Dropbox.