Professional Documents
Culture Documents
Bonus 1: Computer Programming Is The Process of Designing and Building An
Bonus 1: Computer Programming Is The Process of Designing and Building An
The goal of this lab is to get used with basic Java notions introduced so far and selection control
structures. Take a look at the examples and the sample programs in the lecture notes and try to
apply the same concepts and style when writing your own programs. You will write 3 programs,
given below.
1. Use if statements to write a Java program that inputs a single letter and prints out the
corresponding digit on the telephone. The letters and digits on a telephone are grouped this way:
2 = ABC 3 = DEF 4 = GHI 5 = JKL
6 = MNO 7 = PRS 8 = TUV 9 = WXY
No digit corresponds to either Q or Z. For these 2 letters your program should print a message
indicating that they are not used on a telephone.
The program may operate like this (sample output):
Enter a single letter and you will get the corresponding digit on the telephone: R
The digit 7 corresponds to the letter R on the telephone
Another sample:
Enter a single letter and you will get the corresponding digit on the telephone: Z
There is no digit on the telephone that corresponds to Z
NOTE: Your program should accept only uppercase letters (error message for special characters
or lowercase letters)
3. Write a program to assign a letter grade according to the following scheme:
A: total score >= 90
B: 80 <= total score < 90
C: 70 <= total score < 80
D: 60 <= total score < 70
F: total score < 60
Output - the student's total score (float, 2 decimals) and letter grade
Testing - test your program with the following input data:
test1 = 95; test2 = 80; final = 90; assignments = 80
The expected output is: score = 86.25 and letter grade = B.