Note_06 - 101 Multi –way Branching If-Then Handles A 2-choice problem If Age> 65 Then else we either execute(1 or(2 Code-1 Code 2 Code-1 Code 2

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 101 Multi –way Branching If-Then Handles A 2-choice problem If Age > 65 Then else ; we either execute (1) or (2) Code-1 Code - 2 Code-1 Code - 2 102 Problem : Assign the student the correct letter grade based on the following: 90 - 100 A 80 - 89 B 70 - 79 C 60 - 69 D 0 - 59 F Do we have a two-choice problem ? Can I, by using the IF syntax we already know, get the correct letter grade assigned for the student? 103 Program IFExample; var lettergrade : Char; Score : integer; begin writeln ( ‘ Please enter student test score’); Readln ( Score); if (Score > = 90) And (Score < = 100) then lettergrade : = ‘A’; if (Score > = 80) And (Score < = 89) then lettergrade : = ‘B’; if (Score > = 70) And (Score < = 79) then lettergrade : = ‘C’; if (Score > = 60) And (Score < = 69) then lettergrade : = ‘D’; if (Score > = 0) And (Score < = 59) then lettergrade : = ‘F’; writeln (lettergrade); end. (Cont.) 104 (Cont.) (1) Will the above code store the correct grade in the valuable lettergrade? (2) How many if statements will be executed for each student score? Is the solution efficient? 105 Linear Nested-IF 2- Choice problems are handled by: A) Simple IF-Then - Do this code or don’t this code. B) IF-Then-ELSE- Do this code or do that code (Else clause)....
View Full Document

This note was uploaded on 03/27/2008 for the course CPSC 110 taught by Professor Logan during the Spring '07 term at Texas A&M.

Page1 / 15

Note_06 - 101 Multi –way Branching If-Then Handles A 2-choice problem If Age> 65 Then else we either execute(1 or(2 Code-1 Code 2 Code-1 Code 2

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online