Thứ Sáu, 13 tháng 11, 2015

Session8 + Try it yourself

Part I.

1. Calcullating the commission

2. The 'if...else' statement.

3. The 'if...else...if' statement.

4. The 'Nested if' statement.

5.Using the 'switch' statement.

Part II

1. A student appears for a test in 3 subjects. Each test is out of 100 marks. The percentage of each student has to be calculated and depending on the percentage calculated, grades are given as under:
Percentage Grade
>=90          E +
80 - < 90    E
70 - < 80    A +
60 - < 70    A
50 - < 60    B +
< 50           FAIL
To do this :a. Accept the marks of 3 subjects and store in 3 different variables say M1, M2 and M3.b. Calculate the percentage (per = (M1 + M2 + M3) / 3 )c. Check the grade depending on the percentage calculated.d. Display the grade.

Part III.

Bài 1: Declare two variables x and y. Assign values to these variables. Number x should be printed only if it is less than 2000 or greater than 3000, and number y should be printed only if it is between 100 and 500.

Bài 2: Write a program to show your computer’s capabilities. The user types in a letter of the
alphabet and your program should display the corresponding language or package
available. Some sample input and output is given below :
Input                         Output
A or a                           Ada
B or b                           Basic
C or c                           COBOL
D or d                          dBASE III
f or F                            Fortran
p or P                           Pascal
v or V                          Visual C++


Bài 3: Accept values in three variables and print the highest value.








Không có nhận xét nào:

Đăng nhận xét