0% found this document useful (0 votes)
15 views5 pages

Lab 3 - If Else

The document is a lab manual for a Programming Fundamentals course focusing on if-else statements, with a total of 130 marks. It outlines submission guidelines and includes 13 programming tasks that require error handling, no built-in functions, and proper commenting. Each task involves different scenarios such as grade evaluation, bill calculation, and voter eligibility checks.

Uploaded by

emnotttryws2
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)
15 views5 pages

Lab 3 - If Else

The document is a lab manual for a Programming Fundamentals course focusing on if-else statements, with a total of 130 marks. It outlines submission guidelines and includes 13 programming tasks that require error handling, no built-in functions, and proper commenting. Each task involves different scenarios such as grade evaluation, bill calculation, and voter eligibility checks.

Uploaded by

emnotttryws2
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

PUCIT – Programming Fundamentals Lab

Manual
Batch: Add Drop Students​
Lab No.: 03​
Objective: if-else statements​
Total Lab Marks: 130

Submission Guidelines (For Online Students):

●​ Submit your .cpp files in a folder named:​


Lab03_<YourRollNo>
●​ Email it to: mscsf24m001@[Link]
●​ All programs must be properly commented and indented
●​ Email your lab before 3:30 PM sharp​
(Late submissions will not be entertained)
●​ Cheating will result in 0 marks
●​ Error handling is required in every question
●​ Do not use built-in functions​

1. Grade Evaluation with Failing Subject Check

A student receives marks in 5 subjects.

●​ If any subject has marks < 33, they fail, regardless of the total percentage.
●​ If all subjects are passed, assign grades based on total percentage:
○​ A+ (≥90%)
○​ A (≥80%)
○​ B (≥70%)
○​ C (≥60%)
○​ D (≥50%)
○​ F (otherwise)

Write a program that prints "Fail" or the appropriate grade.

2. Dynamic Electricity Bill with Surcharge


Input: Units consumed​
Billing rules:

●​ First 100 units → Rs. 5/unit


●​ Next 200 units → Rs. 7/unit
●​ Beyond 300 → Rs. 10/unit
●​ If total bill > Rs. 2000 → add 15% surcharge

Calculate and print total payable bill.

3. Nested Operation Calculator

Input: 3 numbers and 2 operators (+, -, *, /)​


Calculate expression like a op1 b op2 c respecting operator precedence.​
Use if-else to simulate operator precedence without using eval or built-in functions.

4. Number Pair with Sum Closest to 100

Input: 3 integers​
Determine which pair among them has a sum closest to 100.​
If two pairs are equally close, print the one with the smaller sum.

Example:​
Input: 40, 55, 20​
Output: The pair (40, 55) has the sum closest to 100

5. Intelligent ATM Withdrawal System

Input: Current balance and withdrawal amount​


Rules:

●​ Amount must be a multiple of 500


●​ Balance must be ≥ amount + Rs. 500 (minimum remaining balance)​
If valid, allow withdrawal and show new balance​
Otherwise, show exact reason for rejection​

6. Digit Occurrence Comparator


Input: A 4-digit number​
Count how many even and odd digits it has​
Print which type occurs more, or “Equal” if same​
Restrictions:

●​ No strings
●​ No loops​

7. Smart Parking System

Input: Number of hours parked​


Charges:

●​ First 2 hours → Rs. 50/hour


●​ Next 3 hours → Rs. 30/hour
●​ Beyond 5 hours → Rs. 10/hour​
If total exceeds Rs. 300 → Apply Rs. 50 fine​
Output the total amount to pay​

8. Compare 3 Items with Discount

Input: Prices of 3 items​


Print which item is the cheapest​
If cheapest item’s price > 1000 → apply 10% discount​
Otherwise, print: "No discount"

9. Tax Calculator with Conditions

Input: Annual income and age​


Tax Rules:

●​ ≤250,000 → 0%
●​ 250k–500k → 5%
●​ 500k–1M → 20%
●​ 1M → 30%​
If age > 60 → Apply 10% discount on tax​

Calculate and print:

●​ Tax amount
●​ Net income​

10. Rock-Paper-Scissors with Error Check

Input: Player 1 and Player 2’s choices

●​ 0 = Rock
●​ 1 = Paper
●​ 2 = Scissors

Determine winner using game rules​


If invalid input → print “Invalid Move”​
Handle ties correctly

11. Loan Approval System

Input: Salary and Requested Loan Amount​


Rules:

●​ Minimum salary to apply: Rs. 30,000


●​ Loan is approved if requested amount ≤ 10× salary
●​ Otherwise, rejected with reason

Example:​
Salary: 40,000​
Loan: 500,000​
Output: Rejected: Requested loan exceeds 10 times salary

12. Voter Eligibility Checker

Input: Age and Nationality​


Rules:

●​ Must be 18 or older
●​ Must be Pakistani

Output:
●​ "Eligible to vote"
●​ "Not eligible: underage"
●​ "Not eligible: not a Pakistani citizen"​

13. Odd-Even Sum Checker

Input: 3 integers​
Conditions to check:

●​ If all are even → print "All even"


●​ If all are odd → print "All odd"
●​ If mixed but sum is even → print "Mixed but total is even"
●​ Else → print "Mixed and total is odd"

You might also like