0% found this document useful (0 votes)
51 views3 pages

Multi-Way Selection Structure

Uploaded by

api-250796322
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views3 pages

Multi-Way Selection Structure

Uploaded by

api-250796322
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

b Multi-way selection structure Problem: Design, develop, and test a program that allows users to enter a student's mark

in Mathematics. Determine if the mark is an A, B, , D, or an !, and outputs the student's mark in letter grade. "ere is the marking scheme. A greater than or e#ual to $%, B greater than or e#ual to &%, greater than or e#ual to '%, D greater than or e#ual to (%, ! less than (%. ))variables int mark* ))initiali+ation mark,%* ))processing mark,c.read-nt./* switch . mark)0% / ))mark needs to be an ordinal number 1 case 0%2 case 32 case $2 c.println.4A5/* break* case &2 c.println.4B5/* break* case '2 c.println.4 5/* break* case (2 c.println.4D5/* break* case 62 case 72 case 82 case 02 case %2 c.println.4!5/* break* default2 c.println.49ot a valid number5/* break* :

Alternate Solution int mark,%* mark,c.read-nt./* mark,mark)0%* if .mark ,, $ ;; mark ,, 3 ;; mark ,, 0%/ 1 c.println.4Mark is an A5/* : else 1 if .mark ,, &/ 1 c.println.4Mark is an B5/* : else 1 if .mark ,, '/ 1 c.println.4Mark is an 5/* : else 1 if .mark ,,(/ 1 c.println.4Mark is an D5/* : else 1 if .mark,,6;;mark,,7;;mark,,8;;mark,,0;;mark,,%: 1 c.println.4Mark is an !5/* : else 1 c.println.49ot a valid mark5/* : : : : :

Assignment
0. <est both programs to see if they work 8. reate the flowchart for the 4case structure5 not the multiple 4if = else statements5

7. >ork due by this Thursday hand in flow chart hand out solution update your flow chart re-submit flow chart update your online portfolio

You might also like