You are on page 1of 4

FUNDAMENTALS OF PROGRAMMING AND LOGIC FORMULATION

LAB EXERCISES
1. Design a program that determines if the supply letter is a vowel or a
consonant. Your program must be able to accept either uppercase or
lowercase letters.
2. Create a program that will accept three unique integers and print the
highest integer.
3. Create a program that will accept three unique integers and display the
numbers in ascending order.
4. Write a program that accepts three numbers. If there are equal
numbers, print the product of the equal numbers, otherwise print the
average of the three numbers.
5. Write an if-else statement that outputs the word Passed provided the
value of his exam is greater than or equal to 60 and the number of
programs done is greater than or equal to 10. Otherwise, the if-else
statement outputs the word Failed.
6. A college student who registers for 21 units or more is considered a
fulltime student. The tuition fee is 10,000.a part time student is
charged 300 per unit for tuition. Given the number of units a student is
registering calculate and print his tuition fee based on the basis of the
given criteria.
7. An employees weekly working hours is 40. If an employee exceeds 40
hours, it is considered overtime. Create a program that will accept the
number of hours worked by employee and his/her hourly rate and print
the gross pay and overtime pay rendered, if theres no OT pay to print,
print only the gross pay. To compute for the gross pay of an employee,
multiply the number of hours worked by his/her hourly rate plus his/her
OT pay. The overtime hours rendered should be computed by using
1.50% of his hourly rate.
8. Mary Kettleson wants a program that calculates and displays her
annual bonus, given her annual sales amount. Many receives a 20%
bonus when her annual sales are at least $15,000; otherwise she
receives a 1.5% bonus.
9. Create a program that will determine the toll charge given the
following formula:
Toll charge = vehicle type * kms(based on ticket type)
Vehicle ID Vehicle Type
Charge/km Ticket Type Kms
1
Car
P .50
1
10 kms
2
Light Truck
P.75
2
20 kms
3
bus
P1.00
3
30 kms
4
heavy truck
P5.00
10.
Mr. Jacoby teaches Math at Kindlon High School. He wants a
program that displays a message based on a letter grade he enters.
The valid letter grades and their corresponding messages are shown

below. If the letter grade is not valid, the program should display
Invalid grade.
Letter Grade
Message
A or a
Excellent
B or b
Above Average
C or c
Average
D or d
Below Average
11.
A program should display the message Great Score when a
students test score is at least 90. When the test score is 70 through
89, the program should display the message Good Score!. When the
test score is 0 through 69, the program should display Retake the
test. Note that the perfect score is 100. For all other test scores,
display Invalid test score.
12.
The sales manager at Alden Company wants a program that
displays a price based on a product ID she enters. The valid product
IDs and their corresponding prices are shown below. If the product ID is
not valid, print Invalid Product ID. Message.
Product ID
Price
1
50.55
2
12.35
3
11.46
4
87.95
5
71.64
6
102.33
13.
Create a program that will compute the real estate tax, given the
following formulas:
a. If value of real estate is less than 250, 001.00, tax is 5% of the
real estate value.
b. If value of real estate is between 250, 001.00 to 500,000.00, tax
is 10% of the real estate value.
c. If more than 500,000.00 tax is 15 % of the real estate value.
14.
Professor wants a program that allows him to enter a students
project and test scores. The professor assigns three projects and two
tests. Each project is worth 50 points, and each test is worth 100
points. The program should calculate and display the total points the
student earned on the projects and tests. It should also display the
student grade based on the total points earned. Shown below is the
grading scale that Professor Chang uses when assigning grades.
Total Points Earned
315-350
280-314
245-279
210-244
Below 210

Grade
A
B
C
D
F

Sample Output:
Project and test scores: 45, 40, 41, 96, 89
Total Points earned: 311, B
15.
Write a program that displays Illinois when the state code is 1,
Kentucky when the state code is 2, New Hampshire when its 3,
Vermont, when its 4, and Massachusetts when its 5. If the state
code is not 1 through 5, the program should display the message
Unknown State message.
16.
Write a program that reads in the taxpayers net income and
computes the state income tax due on his net income. The program
computes tax according to the following rate schedule:
a. No tax is paid on the first 15,000 of net income.
b. A tax of 5% is assessed on each dollar of net income from
$15,001 to $25,000.
c. A tax of 12% is assessed on each dollar of net income over
$25,000.
17.
Employees of ABC Electric Corp. are given raise as follows.
Salesperson(15%), Linemen(10%), Engineers(8%). Write a program
that reads in the current weekly salary and then calculate the
employees new weekly salary based on their job category.
18.
Write a program that computes and assesses the TF of student in
one trimester based on the given mode of payment below.
Plan(key)
Discount or Interest
Cash(1)
10% Discount
Two Installments(2)
5% Discount
Three Installments(3)
5% Interest
19.
Implement the following decision table using the nested-if
statement. Assume that point average is within the range 0.0 through
4.0
Grade Point Average
Transcript Message
0.0 0.99
Failed Semester
1.0 - 1.99
On Probation
2.0 2.99
(No Message)
3.0 3.99
Deans List for Semester
4.0 4.99
Highest Honors for Semester
20.
Implement the following decision table using a multiplealternative statement. Assume that wind speed is given as integer.
Wind Speed ( mph)
category
Below 25
Not a strong wind
25 38
Strong Wind
39 54
Gale
55 72
Whole Gale
Above 72
Hurricane
21.
Jennifer Yardley is the owner of Golf Pro, a US company that sells
golf equipment both domestically and abroad. She wants a program

that displays the amount of a salespersons commission. Golf Pros


commission schedule is shown below , along with examples of using
the schedule to calculate the commission on three different sales
amounts. If the sales are less than zero, the program should display
the message the sales cannot be less than 0.
Sales Range
Commission
$0-100,000
multiply the sales by 2%
$100,001-400,000
multiply the sales over 100,000 by
5% and add 2000 to the result
$400,001 and over
multiply the sales over 400,000 by
10% and add 17000 to the result
Example Output:
Sales:
$500,000
Commission: (500,000-400,000)*.1+17,000=27,000
22.
Karlton Learning wants a program that displays the amount of
money a company owes for a seminar. The fee per person is based on
the number of people the company registers, as shown below. If the
user enters a number that is less than or equal to zero, the program
should display an appropriate error message.
Number of registrants
Fee per Person
1-4
$100
5-10
$80
11 or more
$60
23.
Create a program that adds, subtracts, multiplies, or divides two
integers. The program will need to get a letter ( A for addition, S for
subtraction, M for multiplication and D for division) and two integers
from the user. If the user enters an invalid letter, the program should
not ask the user for two integers. Instead, it should display an
appropriate error message. Display the results.
Sample Output:
Please select an operation: S
Input two numbers: 10,5
The difference is 5.
24.
Allenton Water Department wants a program that calculates a
customers total bill. The clerk will enter the current and previous water
readings. The program should calculate and display the number of
gallons of water used and the total charge for the water. The charge for
the water is $7 per 1000 gallons. However, there is a minimum charge
of $16.67. Display the total charge with two decimal places.
25.

You might also like