02 Practice Decision
02 Practice Decision
Objective:
• To get a grip on problem solving based on decision/selection/condition structure.
1. Input age and print the message “eligible” if the age is valid enough to have a driving license
otherwise print “not eligible”.
2. Input an integer value representing the weekday (1, 2, …, 7), and give the day of the week
(Monday, Tuesday, …, Sunday).
3. Write pseudo code, which input a number, and display its absolute value.
4. Check if marks are greater than 80 then print “good luck”, otherwise print “better luck next
time”
6. Input a 4-digit number and display each digit of it separately on screen such that a dash symbol
is placed among each digit.
Sample Run:
Enter a 4-digit Number: 5609
5-6-0-9
7. Julio Cesar Chavez Mark VII is an interplanetary space boxer, who currently holds the
championship belts for various weight categories on many different planets within our solar
system. However, it is often difficult for him to recall what his
"target weight" needs to be on earth in order to make the weight
class on other planets. Write a pseudo code to help him keep
track of this.
It should ask him what his earth weight is, and to enter a number
for the planet he wants to fight on. It should then compute his
weight on the destination planet based on the table below:
So, for example, if Julio weighs 128 lbs. on earth, then he would weigh just under 50 lbs. on
Mars, since Mars' gravity is 0.39 times earth's gravity. (128 * 0.39 is 49.92)
Sample Run 1
Please enter your current earth weight: 128
8. An admission charge for The Little Rep Theater varies according to the age of the person.
Develop a solution to print the ticket charge given the age of the person. The charges are as
follows:
a. Over 55: $10.00
b. 21–54: $15.00
c. 13–20: $10.00
d. 3–12: $5.00
e. Under 3: Free
10.Input from user three numbers and display on screen the largest, second largest and smallest
number of them.
Sample Run 1: Sample Run 2:
Enter three Numbers: 100 Enter three Numbers: 92
34 34
923 92
Largest Number: 923 Largest Number: 92
Second Largest Number: 100 Second Largest Number: 92
Smallest Number: 34 Smallest Number: 34
11.Calculate pay of an employee based on the hours worked. The input includes the employee total
hours worked this week and his hourly pay rate. The employee is to be paid his basic wage for
the first 40 hours worked and 50% more for all the hours above 40 (overtime pay). Output the
regular pay, overtime pay, and total pay for the week. If the employee worked 40 hours or less
then do not display any information about overtime pay.
Sample Run 1 Sample Run 2
Enter Employee Total Hours Worked: 50 Enter Employee Total Hours Worked: 20
Enter Employee Hourly Pay Rate: 10 Enter Employee Hourly Pay Rate: 5
Regular Pay: 400 Regular Pay: 100
Overtime Pay: 150 Total Pay: 100
Total Pay: 550
12.Input marks of a student and display the letter grade and grade point.
a. Policy for letter grade is as follows:
13.Purchase Sheets
A customer needs a specific amount of paper. Following packages are available in market:
1. The charges on the paper are $0.10 for single sheets,
2. $0.055 for amounts in multiples of 100 sheets,
3. $0.04 in multiples of 500 sheets, and
4. $0.03 in multiples of 1000 sheets.
Develop a pseudo code to calculate the type and number of package for the least amount of
money the customer should buy, given the minimum number of sheets the customer needs.
For example, if the customer needs 380 sheets, the amount she would pay when buying at
single sheet rate would be $38, and the amount she would pay when buying in multiples of 100
would be $22.00. However, if the customer bought 500 sheets, the cost would be $20.00. It
would be cost effective for the customer to buy a package of 500 sheets.
14.Input a 3-digit number and check whether it’s a palindrome or not. Palindrome is a word,
phrase, or sequence that reads the same backward as forward. For example, 717 is a
palindrome number, “EYE” is palindrome word.
Sample Run 1 Sample Run 2
Enter a Three Digit Number: 797 Enter a Three Digit Number: 231
797 is Palindrome 231 is not Palindrome