{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

HW3_Curtis_Ryan

# HW3_Curtis_Ryan - 10W-GV HW3 Curtis Ryan Problem ID Scholar...

This preview shows pages 1–4. Sign up to view the full content.

10W-GV 2/2/2011 HW3 Curtis Ryan 1 Problem ID: Scholar: HW3 Problem 1 Problem Statement: To determine the admission price for a single person to a museum depending on the size of the group using logical operators and stacked if statements. Diagram : N/A Solution: Flowchart:

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

View Full Document
10W-GV 2/2/2011 HW3 Curtis Ryan 2 Start Input People (S)=0 If S<3 elseIf S<9 elseIf S<20 Stop Output Individual Price (R)= \$7 Output R= \$6.50 Output R= \$6 elseIf S>20 Output R= \$5 Cost=R*S Output Total Price
10W-GV 2/2/2011 HW3 Curtis Ryan 3 Listing: %This script file will determine the admission price for a single person to a museum depending %on the size of the group. It may include logical operators and uses stacked %if structures. S = input ( 'Enter your group size: ' ); if S <= 3 R = 7.00*S ; %This sets the fee for a single person fprintf ( '\n The total cost of the ticket(s) will be \$%.02f \n' , R); end if S >= 4 && S <= 8 %This says if the group is between 4 and 8 R = 6.50*S ; %Then the price will be 6.50 fprintf ( '\n The total cost of the tickets will be \$%.02f \n' , R); end if S >= 9 && S <=20 %this says if the group is between 9 and 20 R = 6.00*S ; %then the price is 6 dollars and is a small group fprintf ( '\n The total cost of the tickets will be \$%.02f \n' , R); end if S > 20; %if the group is greater then 20 R = 5.00*S ; %then the price will be 5 dollars fprintf ( '\n The total cost of the tickets will be \$%.02f \n' , R); end Sample Run: Enter your group size: 1 The total cost of the ticket(s) will be \$7.00 Enter your group size: 4 The total cost of the tickets will be \$26.00 Enter your group size: 9 The total cost of the tickets will be \$54.00 Enter your group size: 25 The total cost of the tickets will be \$125.00 Discussion: This script uses logical operators which takes more lines and longer to do. This means that there are more chances to mess something up within your algorithm.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 8

HW3_Curtis_Ryan - 10W-GV HW3 Curtis Ryan Problem ID Scholar...

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

View Full Document
Ask a homework question - tutors are online