SlideServe
Menu
Préférences
© SlideServe · v2026

Samples (Selection, Loop, and Function)

axel avatar
15 diapositives · 250 Views · Aug 06, 2014

Calculate average of test grades and determine student's passing status. Input student ID and test grades. Output ID, average grade, passing/failing status. Check for negatives.

Samples (Selection, Loop, and Function) - slide 1
01 / 15Samples (Selection, Loop, and Function)
1 / 17

Télécharger la présentation

Samples (Selection, Loop, and Function)
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  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 student’s 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. Problem 2 • You’ve 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, you’ve been asked to compute the average income for females and the average income for males.

  8. 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

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

  10. Problem 2 Y End? N N Y Female Number of female Total amount (female) Number of male Total amount (male) End

  11. Problem 2 Page 294-296

  12. Problem 3 ***** ***** ***** ***** ***** * ** *** **** ***** 5?   *****  * *** ***** ******* *********

  13. Problem 4 Input Date Seed Date Sunday Total=0; For (i=sm+1; i<im-1;i++) total= total+ days_of_ith_month; Total=Total+ d1 +Id; For example, 2, 30 2%7 = 2, it’s Tuesday 30%7 = 2, it’s Tuesday

  14. Problem 4 Seed Date Sunday Input Date Total=0; For (i=im+1; i<sm-1;i++) total= total- days_of_ith_month; Total=Total- is -days_of_im-id; For example, -5, -33 -5%7 = 2, it’s Tuesday -33%7 =2 , it’s Tuesday