Samples (Selection, Loop, and Function) - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

Samples (Selection, Loop, and Function)

Description:

Your program should calculate the average of three test grades and print out a ... long to accommodate larger values such as nine-digit social security numbers. ... – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 16
Provided by: RPREND4
Learn more at: http://www.cs.wcupa.edu
Category:

less

Transcript and Presenter's Notes

Title: Samples (Selection, Loop, and Function)


1
Samples (Selection, Loop, and Function)
2
Problem 1
  • Many universities send warning notices to
    freshmen who are in danger of failing a class.
    Your program should calculate the average of
    three test grades and print out a students ID
    number, average, and whether or not the student
    is passing. Passing is a 60-point average or
    better. If the student is passing with less than
    a 70 average, the program should indicate that he
    or she is marginal.

3
Problem 1
  • Input student ID number followed by three test
    grades. The student ID number is of type long to
    accommodate larger values such as nine-digit
    social security numbers.
  • Output
  • Echo print
  • ID, average grade, passing/failing, marginal, and
    error message if any of the test scores are
    negative.

4
Problem 1
  • How many selections?
  • Passing?
  • Marginal?
  • Error?

5
Problem 1
Y
Error
  • Sequence?

N
N
Passing?
Y
N
Marginal?
Y
End
6
Problem 1
Page 234-235
7
(No Transcript)
8
Problem 2
  • Youve been hired by a law firm that is working
    on a sex discrimination case. Your firm has
    obtained a file of incomes, incfile, that
    contains the salaries for every employee in the
    company being sued. Each salary amount is
    preceded by F for female or M for male. As a
    first pass in the analysis of this data, youve
    been asked to compute the average income for
    females and the average income for males.

9
Problem 2
  • Input a file, incFile, (run-time filename) of
    floating-point salary amounts, with one about per
    line. Each amount is preceded by a character F
    for female and M for male.
  • Output
  • Echo print
  • Number of females and their average income
  • Number of males and their average income

10
Problem 2
  • Sequence?
  • Repetition?
  • Termination Condition?
  • If selection?
  • Average amount, total amount, number of females
    and males.

11
Problem 2
Y
End?
N
N
Y
Female
Number of female Total amount (female)
Number of male Total amount (male)
End
12
Problem 2
Page 294-296
13
Problem 3


5?
?
?

?

14
Problem 4
Input Date
Seed Date Sunday
Total0 For (ism1 iltim-1i) total total
days_of_ith_month TotalTotal d1 Id For
example, 2, 30 27 2, its Tuesday 307 2,
its Tuesday
15
Problem 4
Seed Date Sunday
Input Date
Total0 For (iim1 iltsm-1i) total total-
days_of_ith_month TotalTotal- is
-days_of_im-id For example, -5, -33 -57 2,
its Tuesday -337 2 , its Tuesday
Write a Comment
User Comments (0)
About PowerShow.com