You are on page 1of 5

Balane, Charisse Yvonne O.

ICT 12-1

SHS Conditional Statement

1. Write a program that asks the user to input two numbers. If the first number entered is greater than the second
number, the program should print the message. “The first number is greater”; else it should print the message
“The first number is smaller.” Test your program by entering the numbers 5 and 8 and then using the numbers
11 and 2. What do you think your program will display if the two numbers are equal? Test this case.

Source Code and Output

2. In a pass/fail course, a student passes if the grade is greater than or equal to 70 and fails if the grade is lower
than 70. Write a program that accepts a grade and prints the message “A Passing grade” or “A failing grade” as
appropriate. How many runs should you make for the program written to verify that it is operating correctly?
What data should you input in each program run?

 One pass or fail is required. The data should be positive integer.

3. If money is left in a particular bank for more than 5 years, the bank pays interest rate of 4.5%; otherwise, the
interest rate is 3.0%. Write a program that uses input to accept the number of years in the variable numyears
and display the correct interest rate, depending on the value input into numyears. How many runs should you
make for the program written to verify that it is operating correctly? What data should you input in each
program run?

 One run is okay. The data type should be integer.

4. Write a program to display the message “PROCEED WITH TAKEOFF” or “ABORT TAKEOFF” depending on the
input. If the character g is entered in the variable code, the first message should be displayed; otherwise, the
second message should be displayed. How many runs should you make for the program written to verify that it
is operating correctly? What data should you input in each program run?

 Two runs, the input should be character type.


5. Write, compile, and run a program that accepts a user-entered number and determines whether it’s even or
odd. The output should display the message “The entered number is even.” Or “The entered number is odd.”
Corresponding to the number the user entered. (Hint: An even number has a 0 remainder when divided by 2.)

6. Write, compile, and run a program to compute and display a person’s weekly salary as determined by the
following conditions: If the hours worked are less than or equal to 40, the person receives $12.00 per hour;
otherwise, the person receives $480.00 plus $18.00 for each hour worked over 40 hours. The program should
request the hours worked as input and display the salary as output.
7. A senior salesperson is paid $800 a week, and the junior salesperson, $500 a week. Write a program that accepts
as input a salesperson’s status in the character variable status. If status equals s, the senior salesperson’s salary
should be displayed; otherwise, the junior’s salesperson’s salary should be displayed.

8. Write a program to display the following two prompts:


Enter a month (use 1 for Jan, etc):
Enter a day of the month:
Have your program accept and store a number in the variable month in response to the first prompt and accept
and store a number in the variable day in response to the second prompt. If the month entered isn’t between 1
and 12, display a message informing the user that an invalid month has been entered. If the day entered isn’t
between 1 and 31, display a message informing the user that an invalid day has been entered.
9. Write, compile, and run a program that accepts a character as input data and determines whether the character
is a lowercase letter. A lowercase letter is any character that’s greater than or equal to “a” and less than or equal
to “z”. If the entered character is a lowercase letter, display the message. “The character just entered is a
lowercase letter.” If the entered letter isn’t a lowercase, display the message. “The character just entered is not
a lowercase letter.”

10. Write, compile and run a program that asks the user to input two numbers, check the numbers. If the first
number entered is greater than the second number, the program should print the message, “The first number is
greater.”; otherwise, it should print the message “The first number is not greater than the second.” Test your
program by entering the numbers 5 and 8 and then using the numbers 11 and 2. What will your program display
if the two numbers entered are equal?

You might also like