0% found this document useful (0 votes)
16 views1 page

CSCE106 Lab Session 6

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

CSCE106 Lab Session 6

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

The American University in Cairo

Computer Science & Engineering Department


CSCE 1001 – Fundamentals of Computer Science
Lab Session 6 Programming of One-way Selections

Objectives:

- To become familiar with the control structures: sequence and selection.


- To learn how to compare numbers, characters, and strings.
- To learn how to use the relational and logical operators to write expressions that are type bool.
- To learn how to write one-way and two-way selection statements.
- To learn how to implement decisions in algorithms using the if statement.

Problems:
Write a C++ program or each of the following problems:

1. Draw a Flow chart and write a program in C++ that reads three scores of a student in three tests
to compute and display the largest score.

2. Draw a Flow chart and write a program in C++ that reads three scores of a student in three tests
to compute and display the smallest score.

3. Draw a Flow chart and write a program in C++ that reads three scores of a student in three tests
to compute and display the smallest and largest scores.

4. Draw a Flow chart and write a program in C++ that reads three scores of a student in three tests
to compute and display the sum of the best-two scores.

5. Community Hospital needs a program to compute and print a statement for each patient. Charges
for each day are as follows:
a) Room charges: private room, $125.00; semiprivate room, $95.00; or ward, $75.00
b) Telephone charge: $1.75
c) Television charge: $3.50
Write a program to get one string of four characters from the keyboard, the first character is an
integer value indicating the number of days spent in the hospital, and the others are three
alphabet characters. Typical input is: 5PNY
where 5 indicates the number of days spent in the hospital, P represents the room type (P, S, or
W), N represents the telephone option (Y or N), and Y represents the television option (Y or N).

Instructions:

- The TA solves problems 1 (20 minutes)


- The TA asks students to solve and submit in-Lab problem 2 & 3 (30 minutes)
- The TA can give a hint how to use the string method s.at(index) which is required to solve problem 5.
- The TA asks students to solve problem 4 & 5 and submit before the next Lab session.

You might also like