0% found this document useful (0 votes)
3 views6 pages

Lab Task 5

Uploaded by

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

Lab Task 5

Uploaded by

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

PROGRAMMING

FUNDAMENTALS
LAB TASK NO:5
IT DEPARTMENT (CYBER SECURITY)
PAK AUSTRIA FACHHOCHSCHULE APPLIED SCIENCE AND
TECHNOLOGY

SUBMITTED TO:
SIR SAAD QAYYUM
SUBMITTED BY:
SARDAR SHAHEER QAISER
REGISTRATION NO#

B24F0482RO025
TOPIC:
LAB 5
SUBMISSION DATE:
11/10/2024
Problem Statement 01: Check if a Character is a Vowel or Consonant
Explanation:
In this program, the user enters a single character. The program checks if this character is a
vowel (a, e, i, o, u) or a consonant. We consider both uppercase and lowercase letters, so we
handle both A and a, for example.

Explanation of Code
1. Input Character: We take a character input from the user.
2. Condition Check: We use if statements to check if the character matches any of the vowels
(both lowercase and uppercase).
3. Output Result: Based on the check, it prints either "It is a vowel" or "It is a consonant".
----------------------------------------------------------------------------------------------------------

Problem Statement 02: Travel Time Calculation


Explanation
The program calculates the time it will take to travel a specified distance using different transportation
methods: walking, bicycling, or driving a car. Each mode of transport has a predefined speed in km/h.

Explanation of Code:
1. Input Distance: The user inputs the distance between two points in kilometers.
2. Calculate Time for Each Mode:
o We calculate the travel time by dividing the distance by the speed for each mode
(walking, biking, and driving).
3. Display Results: The program displays the time required for each mode of transportation.

Problem Statement 03: Check Right-Angle Triangle


Explanation
This program checks whether three given side lengths form a right-angle triangle using the Pythagorean
theorem. If c^2 = a^2 + b^2, then the triangle is a right-angle triangle, where c is the hypotenuse
(longest side).

Explanation of Code
1. Input Sides: The user provides three side lengths: base, perpendicular, and hypotenuse.
2. Check Right-Angle Condition: Using the Pythagorean theorem, we check if the square of the
hypotenuse is equal to the sum of the squares of the other two sides.
3. Display Result: It displays whether the sides form a right-angle triangle.
-----------------------------------------------------------------------------------------------------------
Problem Statement 04: Income Tax Calculator
Explanation
The program calculates income tax based on predefined tax slabs. It uses the user's salary as input to
determine the tax amount and the final salary after tax deduction.
Explanation of Code
1. Input Salary: The user enters their annual salary.
2. Calculate Tax Based on Slabs:
o The program applies different tax rates based on income levels.
o For example, if the salary is greater than 600,000 but less than or equal to 1,200,000,
the tax rate is 5%.
3. Display Tax and Net Salary: The program displays both the calculated tax and the final salary
after deduction.
-----------------------------------------------------------------------------------------------------------
Problem Statement 05: 4x4 Grid Game
Explanation
This program simulates a 4x4 grid game where a player can move in one of four directions (Up, Down,
Left, Right) starting from a given position. The program checks if the move will collide with an obstacle.
Explanation of Code
1. Input Positions:
o The user provides the player's initial position and the obstacle's position on the 4x4
grid.
2. Handle Movement:
o Based on the move direction, we update the player's position, ensuring they stay
within grid boundaries.
3. Check for Collision:
o If the player’s new position matches the obstacle’s position, it displays a collision
message.
-----------------------------------------------------------------------------------------------------------
Problem Statement 06: Electricity Bill Calculation
Explanation
The Program takes the number of electricity units consumed by the user and calculates the total bill
using predefined slab rates. After calculating the base bill according to the slab, it adds a 17% GST.
Explanation of Code
1. Input Units: The user enters the number of units consumed.
2. Determine Rate: Using if-else statements, the program determines the rate per unit based on
the slab.
3. Calculate Base Bill: The program calculates the base bill by multiplying the units consumed by
the rate.
4. Add GST: A 17% GST is added to the base bill to calculate the total bill.
5. Display Results: The program outputs both the base bill and the total bill including GST.
-----------------------------------------------------------------------------------------------------------

You might also like