0% found this document useful (0 votes)
5 views2 pages

02 Practice Decision

The document outlines a programming practice assignment for CMP-140 Programming Fundamentals, focusing on problem-solving using pseudo code. It includes various tasks such as determining eligibility for a driving license based on age, calculating weights on different planets, and computing employee pay based on hours worked. Additional exercises involve checking for palindromes, determining ticket prices based on age, and finding the largest and smallest numbers among three inputs.

Uploaded by

mabdullahkhayoo3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

02 Practice Decision

The document outlines a programming practice assignment for CMP-140 Programming Fundamentals, focusing on problem-solving using pseudo code. It includes various tasks such as determining eligibility for a driving license based on age, calculating weights on different planets, and computing employee pay based on hours worked. Additional exercises involve checking for palindromes, determining ticket prices based on age, and finding the largest and smallest numbers among three inputs.

Uploaded by

mabdullahkhayoo3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CMP-140 Programming Fundamentals

BS SE/CS Fall 2018 Issue Date: 13-Feb-2019


Practice - 02

Objective:
• To get a grip on problem solving based on decision/selection/condition structure.

Devise Solution of the following problems using Pseudo Code

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”

5. Check whether a number A is divisible by another number B.

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

I have information for the following planets:


1. Venus 2. Mars 3. Jupiter
4. Saturn 5. Uranus 6. Neptune

Which planet are you visiting? 2


Your weight would be 49.92 pounds on that planet.

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

9. Determine the status of students (Safe/Dropped/Probation). Student is dropped if CGPA is less


than 1.7, on probation if CGPA is greater than or equal to 1.7 but less than 2.0, otherwise
student is safe.

PUCIT, University of the Punjab, Lahore, Pakistan. Page 1 of 2


© Fareed Ul Hassan Baig
CMP-140 Programming Fundamentals
BS SE/CS Fall 2018 Issue Date: 13-Feb-2019
Practice - 02

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

PUCIT, University of the Punjab, Lahore, Pakistan. Page 2 of 2


© Fareed Ul Hassan Baig

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy