Docsity

Lab Assignment 5 on Problem Solving-Programming Concepts I | CIS 120, Lab Reports of Computer Science

Toggle sidebar
bg1
Name:__________________________________________________________________Section:___________
CIS 120-101 / Overstreet / Fall 2007
Lab 5 โ€“ Due: Week 5 (Wed 9/19/07)
Problem Description
Write a program that will prompt the user to enter the number of a month (1=jan, 2=feb โ€ฆ 12=dec) and a year (4 digits from 1000 to
9999, ex: 2008 not 08). If both inputs are valid the program will compute and output the number of days in the given month, the name
of month, and the year. Make sure to account for the month of February in leap years. See sample output format (with proper month
used) on next page
Code Requirements:
It is expected that your program will use a switch expression (based on user input month number) to determine how many days there
are in the given month and the month name. The 2-case (February) will require you to determine if the input year is a leap year and
assign the number of days accordingly. The code to do this can be found in chapter 3 (pg 72).
Error Checking:
If the user inputs a year that is outside of the range 1000-9999, the program should output an error message and terminate. If the user
inputs a month outside of the range 1-12, the program should output an error message and terminate. You can use the default case of
the switch expression to handle errors in input for the month number. You are not expected to handle error cases of non-int String
input.
Problem Analysis
Input: Month (number 1-12) and year (4 digit).
Process: Determine how many days there are in that month and the name of the month.
Output: Number of days, name of the month, year.
Pseudocode
1. Prompt the user to input the year
2. Check for valid year
a. if invalid: output error message and terminate
3. Prompt the user to input the month
4. Determine how many days there are in that month and year and the month name
a. all valid cases except february: assign corresponding name and number of days
b. february case: assign name and determine if the input year is a leap year (code found in chapter 3)
i. if non leap year โ€“ 28 days
ii. if leap year โ€“ 29 days
c. invalid cases(default case): output error message and terminate
5. Display number of days, month name, and year
Deliverables
You must submit a printed and electronic (CD or Floppy) copy of your commented program along with completed data
dictionary, completed test design table, and screenshots of executions of your test design cases in a manila envelope.
Data Dictionary
Variable Name Type Usage
Test Design (To be completed by hand before program implementation. Use this to verify program output)
Test Case month number year number of days name of month
1
2
3
4
5
pf3

Partial preview of the text

Download Lab Assignment 5 on Problem Solving-Programming Concepts I | CIS 120 and more Lab Reports Computer Science in PDF only on Docsity!

Name:__________________________________________________________________Section:___________

CIS 120-101 / Overstreet / Fall 2007

Lab 5 โ€“ Due: Week 5 (Wed 9/19/07)

Problem Description Write a program that will prompt the user to enter the number of a month (1=jan, 2=feb โ€ฆ 12=dec) and a year (4 digits from 1000 to 9999, ex: 2008 not 08). If both inputs are valid the program will compute and output the number of days in the given month, the name of month, and the year. Make sure to account for the month of February in leap years. See sample output format (with proper month used) on next page Code Requirements: It is expected that your program will use a switch expression (based on user input month number) to determine how many days there are in the given month and the month name. The 2-case (February) will require you to determine if the input year is a leap year and assign the number of days accordingly. The code to do this can be found in chapter 3 (pg 72). Error Checking: If the user inputs a year that is outside of the range 1000-9999, the program should output an error message and terminate. If the user inputs a month outside of the range 1-12, the program should output an error message and terminate. You can use the default case of the switch expression to handle errors in input for the month number. You are not expected to handle error cases of non-int String input. Problem Analysis Input: Month (number 1-12) and year (4 digit). Process: Determine how many days there are in that month and the name of the month. Output: Number of days, name of the month, year. Pseudocode

  1. Prompt the user to input the year
  2. Check for valid year a. if invalid: output error message and terminate
  3. Prompt the user to input the month
  4. Determine how many days there are in that month and year and the month name a. all valid cases except february: assign corresponding name and number of days b. february case: assign name and determine if the input year is a leap year (code found in chapter 3) i. if non leap year โ€“ 28 days ii. if leap year โ€“ 29 days c. invalid cases(default case): output error message and terminate
  5. Display number of days, month name, and year Deliverables You must submit a printed and electronic (CD or Floppy) copy of your commented program along with completed data dictionary, completed test design table, and screenshots of executions of your test design cases in a manila envelope.

Data Dictionary

Variable Name Type Usage Test Design (To be completed by hand before program implementation. Use this to verify program output) Test Case month number year number of days name of month 1 2

Sample 1 (valid input) : Sample 2 (valid input, leap year) :

Sample 3 (invalid month number) : Sample 4 (invalid year) :