Professional Documents
Culture Documents
PF Assignment 2
PF Assignment 2
ISLAMABAD
Programming Fundamentals (CS 1002)
FALL 2023 ASSIGNMENT # 2
Plagiarism: Plagiarism cases will be dealt with strictly. If found plagiarized, both the involved
parties will be awarded zero marks in this assignment, all of the remaining assignments, or even
an F grade in the course. Copying from the internet is the easiest way to get caught!
Deadline: The deadline to submit the assignment is 20th September 2023 at 11:59 PM. Late
submission with marks deduction will be accepted. Correct and timely submission of the
assignment is the responsibility of every student; hence no relaxation will be given to anyone.
Modular code: Divide your code in user defined functions where appropriate. Every unit
functionality should be implemented in a separate function. All problems solved with just the
main function will be awarded zero marks.
Tr Tr Tr Tr T T T T T T T T T T T T
47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32
T T T T T T T T T T T T T T T T
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
C C C C C C C C C C C C C C C C
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
C C C C C C C C C C C C C C C C
a) Develop a function to extract the customer ID from the 64-bit number using bitwise operations.
b) Another function to extract transaction ID.
c) Function to extract transaction type.
d) For enhanced security, your task is to invent a unique encryption method. Write a function to
encrypt the 64-bit number (X) using a custom encryption algorithm that you design. The
decryption function should be created as well, to recover the original 16-bit value.
The details and mechanics of your custom encryption algorithm are entirely up to your ingenuity. You
should aim to make it both robust and challenging to decipher.
Problem 2: FAST-NU’s 74th convocation is on 21st October 2023. You are required to create a Booking
System for the graduating students and their guests. A student is allowed to bring in no more than 4
guests out of which two will be adults and two can be children between ages 10 to 17. For each guest
the cost of one ticket is Rs. 1500/-, and parking per hour is Rs. 100/-.
Sample output: 1
Please enter your name: Muhammad Ali
How many guests will accompany you? 4
Are there any children among them, remember children under the age of 10 are not allowed?
Yes How many children between 10 to 17 will accompany you? 2
Sample output: 2
Please enter your name: Muhammad Ali
How many guests will accompany you? 5
Registration failed!!!
For any input which is not allowed display the message “Registration failed”.
Problem 3 – Expected Monitory Value (EMV): EMV is one of the techniques used for quantitative risk
analysis. It is used to calculate cost of each decision alternatives available in the project to choose the
cost effective and best decision, using Decision Tree analysis. It helps project managers in decision
making during a project.
A project manager is required to also have exotic plants in a botanic garden that he is setting up. Now he
is in a dilemma of whether to buy them or grow them. Decision tree (above) shows the cost of growing
exotic plants ($60K) vs buying them from a vendor ($40K). This makes it an easy decision to just look at
the dollar value and since he/she will end up spending $20K more when growing them. The better
decision is to buy them from a vendor.
Sadly, these analyses are not that straightforward and involve various other external factors. In this
scenario, depending on the weather conditions the potential dollar value that will be added to the
botanical garden will vary. If the weather is favorable the person ends up making $80K when he chooses
to grow these exotic plants versus $60K when he chose to buy them from a vendor. This makes this
problem confusing, as only taking this factor into consideration now growing these plants seems
favorable.
Looking at individual paths will not help the PM in coming to a decision. He/she has to calculate EMV of
both decisions. Here is how EMV for both decisions can be calculated:
EMV of the decision (grow plants) = ($80K-$60K) * 0.7 + ($50K-$60K) * 0.3 = $11K
EMV of the decision (buy from vendor) = ($60K-$40K) * 0.7 + ($40K-$40K) * 0.3 = $14K Since
the EMV of decision (buy from vendor) is better than the other. It is a less risky decision.
You have to implement this decision tree in C++ so that the PM can use it for risk analysis. You cannot use
the probabilities written in the decision tree. You must run this tree 20 times for every decision (grow or
buy), and in each run randomly select between favorable weather or harsh weather. Use these numbers
to replace the probabilities in the tree.
Problem 4 – Cricket Fortune Teller: In this problem, you are required to build a system that will predict
the winner of the current world cup. There are 10 teams in the tournament and every team will play
against the other. The top four teams will qualify for the semifinals, where the firstsemifinal will be
played against the 1st and 4th team and the second semifinal will be played against 2nd and 3rd team.
Final will be played against the winners of these semifinals.
You can use a random number to simulate the toss. For every match, you can generate a random number
to declare the winner of the match. While deciding the winner also take into consideration win-loss ratio
of the two teams competing which will be taken as an input from the user.
You are required to use if-else (if-else-if) structure to run the tournament and generate one complete
winning scenario randomly. The names of the teams are as below:
1. Afghanistan
2. Australia
3. Bangladesh
4. England
5. India
6. Netherlands
7. New Zealand
8. Pakistan
9. South Africa
10. Sri Lanka
Problem 5: Compose a C++ program that takes the order from the user and calculates the bill
accordingly. System should also add some discount on the respective bill that exceeds the limit of the
payment. The discount should be added according to the following table:
Order amount Dine in Delivery Takeawa
y
Problem 6: Write a C++ program that implements the following loan approval. Your program should lead
a person through the steps to help a customer. Given below is the flow chart.
Sample output 1:
Enter salary of the customer: Rs. 200,000/-
Loan amount requested: Rs. 1,000,000/-
Loan amount > 50% of Salary: Yes
***Loan Rejected***
Sample output 2:
Enter salary of the customer: Rs. 200,000/-
Loan amount requested: Rs. 1,00,000/-
Loan amount > 50% of Salary: No
Problem 7: You are given a 9*9 grid as shown in the figure below. You can determine the color of each
square from the grid. The number of each square is also shown below. Write a C++ program for this
below given grid. The user is given two options to select from.
1 2 3 … … 7 8 9
10 11 12 … … 18
… 34 35 36 …
64 65 66 …
… 79 80 81
a) When the user selects 1st option, the user will enter number of square in this grid (any number
from 1-81). Your program will determine the color of the square.
b) When the user enters 2nd option, the user will enter two numbers from this grid. Your program
will determine if the two squares entered in this 9*9 grid have same color or not.
Problem 8: FAST-NUCES has expanded its operations to a great extent and it needs an automated
helpline system for its One Stop Student Center. In order to develop the system, FAST-NUCES has hired
the best programmers from its Islamabad campus. You are required to develop the following scenario
for the helpline system using switch-case construct in C++.
FAST-NUCES has five campuses at Islamabad, Lahore, Karachi, Peshawar, and Faisalabad in Pakistan.
Your system shall cater for all the campuses and provide the following scenario:
Welcome to FAST-NUCES! Press 1 for Islamabad campus. Press 2 for Lahore campus. Press 3 for Karachi
campus. Press 4 for Peshawar campus. Press 5 for Faisalabad campus. Press 0 to talk to an operator. 1)
Welcome to Islamabad campus.
Press 1 for admission related queries.
Press 1 for admission in school of computing
Please enter your query: (user shall enter a text message here)
Your query is registered. We will get back to you soon.
Press 2 for admission in school of electrical engineering
Please enter your query: (user shall enter a text message here)
Your query is registered. We will get back to you soon.
Press 3 for admission in school of management sciences
Please enter your query: (user shall enter a text message here)
Your query is registered. We will get back to you soon.
Press 2 for academics related queries.
Press 1 to apply for a degree/transcript generation
Please enter your query: (user shall enter a text message here)
Your query is registered. We will get back to you soon.
Press 2 to freeze your semester
Please enter your query: (user shall enter a text message here)
Your query is registered. We will get back to you soon.
Press 3 to add/drop courses
Please enter your query: (user shall enter a text message here)
Your query is registered. We will get back to you soon.
Press 3 for accounts and fees related queries.
Press 1 for queries related to fee challan generation
Please enter your query: (user shall enter a text message here)
Your query is registered. We will get back to you soon.
Press 2 to apply for financial aid
Please enter your query: (user shall enter a text message here)
Your query is registered. We will get back to you soon.
Press 3 apply for a scholarship
Please enter your query: (user shall enter a text message here)
Your query is registered. We will get back to you soon.
Press 4 for information technology related queries.
Press 1 to apply for an email id generation
Please enter your query: (user shall enter a text message here)
Your query is registered. We will get back to you soon.
Press 0 to talk to an IT expert
Please wait.
Press 5 for sports related queries.
Press 1 to get a sports venue booked
Please enter your query: (user shall enter a text message here)
Your query is registered. We will get back to you soon.
Press 0 to talk to a representative
Please wait
If you know your desired extension, please dial it directly.