ITSC121S2020Lab3

From BU Computer Science
Jump to navigation Jump to search

Third Lab, ITSC 121, Spring 2020

Overview

Write 3 different programs dealing with loops from chapter 5.

Details of program 1

This is problem 5.11. Write a program that reads an unspecified number of integers, determines how many positive and negative values have been read and computers the total and average of the input values (not counting zeros). Your program ends with the input 0. Determine the average as a floating point number. Here are two sample runs:

  • Enter an list of integers. The input ends when 0 is entered: 1 2 -1 3 0
  • The number of positives is 3.
  • The number of negatives is 1.
  • The total is 5.0.
  • The average is 1.25



  • Enter an list of integers. The input ends when 0 is entered: 0
  • No numbers were entered except 0.

Details of program 2

This is problem 5.10. Write a program that displays all of the numbers from 100 to 1,000 (10 per line) that are divisible by 5 and 6. Numbers are separated by exactly one space.

Details on program 3

This is an adaptation of problem 5.18. Write one program to produce the following output. It must use loops for each pattern. Output
Pattern A
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
Pattern B
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Pattern C
               1
            2 1
         3 2 1
      4 3 2 1
   5 4 3 2 1
6 5 4 3 2 1
Pattern D
6 5 4 3 2 1
   5 4 3 2 1
      4 3 2 1
         3 2 1
            2 1
               1

Extra credit

For the third problem: Let the user enter a number between 1 and 9 and use that for the number of lines (and limit for the max. number of digits per row). More extreme challenge: Let the user enter any number and have the program adapt spaces (so that if two digit numbers are allows 2 spaces separate 1 digit numbers. If three digit numbers are allow, 3 spaces separate 1 digit numbers and 2 spaces separate 2 digit numbers, etc.)

Details about all programs

  1. Include proper comments for all
  2. Use proper formatting, etc.
  3. Test with more than one set of data
  4. Get the correct data outputted on all programs before worrying about formatting

Submissions

  1. Create a software development report that includes the following for each program:
    • A problem summary (the big picture)
    • A list of requirements. (Things that this particular implementation of a solution must do)
    • A list of steps your program does
    • A testing report: What exact input you used and what output you got.
    • How long it took to write the program
    • Who you got help from (if you got help)
    • Changes (if any) you would make if you had more time and/or skill
    • At least two things you learned while writing all the programs
  2. Create a zip folder with your software development report(s) and your java files and submit that to canvas.
  3. Due date can be found on canvas