Programming Fundamental Problems
Programming Fundamental Problems
Submission Instructions:
• All questions must be solved manually on plain A4 papers and submitted in the specified order as a hard
copy.
• A cover page must be included with the assignment.
• This is an individual assignment, collaboration is not allowed.
• Submit your own original work. Plagiarism will not be tolerated, either done from the internet or from any
fellow.
• Any submission that does not adhere to these instructions will not be evaluated.
• Deadline: September 19, 2024 by 4:00 P.M
Question 01: Write pseudo codes and draw flowcharts of the following:
1. Semester Bill
A university charges $3000 per semester for in-state tuition and $4500 per semester for out-of-state tuition. In
addition, room and board is $2500 per semester for in-state students and $3500 per semester for out-of-state
students. Write an application that asks the user for their residential status (i.e., in-state or out-of-state) and
whether they require room and board (Y or N). The program should then compute and output their bill for that
semester. Use the sample outputs below for a better understanding (do not hard code, your program should run
for any input).
Sample Run 1:
Please input "I" if you are in-state or "O" if you are out-of-state:
I
Please input "Y" if you require room and board and "N" if you do not:
N
Your total bill for this semester is $3000
Sample Run 2:
Please input "I" if you are in-state or "O" if you are out-of-state:
O
Please input "Y" if you require room and board and "N" if you do not:
Y
Your total bill for this semester is $8000
Page 1
National University
Of Computer & Emerging Sciences Faisalabad-Chiniot Campus
2. Maximum Numbers
Take five integers from the user and print 2nd maximum and 3rd maximum among them.
3. Handshakes
On your first day at university, the teacher suggested that it would be a good idea for each student to meet every
other student in the class. The teacher said, "When you meet, please shake hands and introduce yourself by
name." Write a program that prints total number of handshakes in a class where N is the number of students. (N
can be any positive number)
4. Serve Oil
You have two drums of capacity of 8 liters and 5 liters. You also have an unlimited supply of oil, but there are no
marks on the drums to measure the oil directly.
Your task is to find a way to get exactly 1 liter of oil using these two drums. You can fill the drums, pour oil from
one drum to the other, or empty the drums as needed.
5. Sequences
Print the following Sequences (using while- loop): Without loop the solution will be unacceptable.
Make the program generic in terms of sequence size taken from user.
6. Prime Numbers
Take a number n from user as input and print the number of prime digits present in that number.
Eg:
Input:
n = 287643
Output:
3
Page 2
National University
Of Computer & Emerging Sciences Faisalabad-Chiniot Campus
Eg:
Input:
b=2
p=4
Output:
16
8. Perfect Square
Take a positive integer n as input. Your program must show whether this n is a perfect square or not.
9. Expense Tracker
Ali has a unique routine for his weekend shopping, but this time he has a slightly more complicated plan to
manage his expenses and savings. Every Saturday, Ali goes shopping with a wallet that contains random
amounts of money. Before starting his journey, he pulls out a random amount of money from his wallet to cover
his expenses. If he pulls out more than 150 rupees, he takes a cab to the mall, where the fare is 40 rupees each
way. If the amount he pulls out is between 100 and 150 rupees, he takes a rickshaw to the mall, which costs 25
rupees each way. If Ali pulls out between 50 and 100 rupees, he takes the bus, where the fare is 10 rupees for a
one-way trip. If he pulls out less than 50 rupees, Ali walks to the mall for free.
At the mall, Ali has a few priorities for his shopping. First, he buys groceries, which cost a fixed 40 rupees
regardless of how much money he has left. After paying for the groceries, if he still has at least 50 rupees left, he
purchases a meal at the food court, which costs 30 rupees. Once his transportation, groceries, and potential
meal expenses are accounted for, Ali spends the remaining money on gadgets, with each gadget costing 20
rupees. After purchasing as many gadgets as he can afford, if there is any leftover money, he puts it back into his
wallet for future savings.
Page 3
National University
Of Computer & Emerging Sciences Faisalabad-Chiniot Campus
7.5 K <- K + 1
8.0 END WHILE
9.0 STOP
O===O
\O/
|
/\
Thinking in power...!
Good luck
Page 4