You are on page 1of 19

PROGRAMING FUNDEMENRTAL ( LAB ) ASSIGNMENT :

BY: SIR FURQAN ABBASI

CLASS ID # 102256

STUDENT ID # 10575

STUDENT NAME: KAMRAN ANJUM.

PROBLEM NO#01: Customers can withdraw cash from an Automatic Teller


Machine (ATM).

is refused if amount entered > daily limit

Write a program which inputs a request for a sum of money, decides if a


withdrawal can be made and calculates any charges. Appropriate output
messages should be included.

CODING:
Console.Write("Enter Amount = ");
int amount = Convert.ToInt32(Console.ReadLine());
double crntBlnc = 100000;
const int dailyLimit = 25000;
if (amount > crntBlnc)
{
Console.WriteLine("Current Blance Is Low ");
}
else if (amount > dailyLimit)
{
Console.WriteLine("Amount You Entered is Exceded From Daily Limit" );
}
else if (crntBlnc < 5000)
{
double charge = amount * 0.02;
crntBlnc -= amount + charge;
Console.WriteLine("Current Blance1 = " + crntBlnc);
}
else if (crntBlnc >= 5000)
{
crntBlnc -= amount;
Console.WriteLine("Current Blance2 = " + crntBlnc);
}

Console.ReadLine();

CMD SCREENSHOT:

PROBLEM NO#02: Write a program, which

(E.g. 147 would give an output of 3, 147) (Without using Math.Log10()


Method)

CODING:
Console.Write("Enter a Whole Number = ");
int num = Convert.ToInt32(Console.ReadLine());

if (num >= 0 && num < 10)


{

Console.Write("01 Digit");
}
else if (num >= 10 && num < 100)
{

Console.Write("02 Digits");
}

else if (num >= 100 && num <1000)


{
Console.Write("03 Digits");
}
else if (num >= 1000 && num < 10000)
{

Console.Write("04 Digits");
}
else if (num >= 10000 && num < 100000)
{

Console.Write("05 Digits");
}
else if (num >= 100000 && num < 1000000)
{

Console.Write("06 Digits");
}
else
{
Console.Write("Unable To Count Digits");
}

Console.WriteLine("," + num);
Console.ReadLine();

CMD SCREENSHOT:

PROBLEM NO#03: The current year and the year in which the employee
joined the organization are entered through the keyboard. If the number of
years for which the employee has served the organization is greater than 3
then a bonus of Rs. 2500/- is given to the employee. If the years of service
are not greater than 3, then the program should do nothing.

CODING:
Console.Write("Enter Current Year = ");
int curntYear = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter Joined Year = ");
int joinYear = Convert.ToInt32(Console.ReadLine());
int result = curntYear - joinYear;
Console.WriteLine("Total Years of Employment = " + result);
int Bonus;
if(result>=3){
Bonus = 2500;
Console.WriteLine("Employee Total Bonus On Salary = " + Bonus);
}
else{
Console.WriteLine("Employee Total Bonus On Salary = " + 0 );
}
Console.ReadLine();

CMD SCREENSHOT:

PROBLEM NO#04: Team nascent innovations is a software house that

developer is married.

28 years of age.

In all other cases, the software developer is not insured. If marital Status,
gender and age of the software developer are user-defined, write a program
to determine whether the software developer is to be insured or not.

CODING:
Console.WriteLine(" Note: PLEASE ENTER FIRST WORD IN CAPITAL ");
Console.Write("Enter Marital Status = ");
string s = Console.ReadLine();

if (s == "Married")
{

Console.WriteLine("Ensured");
}
else
{
Console.Write("Enter Gender = ");
string g = Console.ReadLine();
Console.Write("Enter Age = ");
int a = Convert.ToInt32(Console.ReadLine());
if (s == "Unmarried" && g == "Male" && a >= 28)
{

Console.WriteLine("Ensured");
}
else if (s == "Unmarried" && g == "Female" && a >= 22)
{

Console.WriteLine("Ensured");
}
else
{
Console.WriteLine("Not Ensured");
}
}

Console.ReadLine();

CMD SCREENSHOT:

PROBLEM NO#05: Any year is input through the keyboard. Write a program
to determine whether the year is a leap year or not

CODING:
Console.Write("Enter Year = ");
int year = Convert.ToInt32(Console.ReadLine());

if ((year % 4) == 0)
{

Console.WriteLine(" Leap Year ");


}
else
{
Console.WriteLine(" Not A Leap Year ");
}
Console.ReadLine();

CMD SCREENSHOT:
PROBLEM NO#06: Write a program to check whether a triangle is valid or
not, when the three angles of the triangle are entered through the
keyboard. A triangle is valid if the sum of all the three angles is equal to 180
degrees.

CODING:
Console.Write("Enter 1st Side Angle Of Triangle = ");
int a1 = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter 2nd Side Angle Of Triangle = ");
int a2 = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter 3rd Side Angle Of Triangle = ");
int a3 = Convert.ToInt32(Console.ReadLine());
int sum = a1 + a2+ a3;
Console.Write("Sum Of All Three Sides OF Triangle = " + sum + " And ");
if (sum == 180)
{
Console.WriteLine("Triangle Is Valid");
}
else
{
Console.WriteLine("Triangle Is Not InValid");
}
Console.ReadLine();

CMD SCREENSHOT:

PROBLEM NO#07: A library charges a fine for every book returned late. For
first 5 days the fine is 50 Rs, for 6-10 days fine is 100 rupee and above 10
days fine is 150 rupees. If you return the book after 30 days your
membership will be cancelled. Write a program to accept the number of
days the member is late to return the book and display the fine or the
appropriate message.

CODING:
Console.Write("Enter The Number Of Days The Book Is Late = ");
int day = Convert.ToInt32(Console.ReadLine());

if (day == 0)
{
Console.WriteLine("No Fine");
}
else if (day <= 5)
{
Console.WriteLine("Fine = Rs 50");
}
else if (day <= 10)
{
Console.WriteLine("Fine = Rs 100");
}
else if (day <= 30)
{
Console.WriteLine("Fine = Rs 150");
}
else if (day > 30)
{
Console.WriteLine("Membership Cancelled");
}

Console.ReadLine();

CMD SCREENSHOT:

PROBLEM NO#08: In a company an employee is paid as: If Basic Salary of


employee is less than Rs. 15,000, then Rental Allowance = 10% of Basic
Salary and Dining Allowance = 90% of Basic Salary. If his salary is either equal
to or above Rs. 15,000 but less than Rs. 20,000 then Rental Allowance = Rs.
500 and Dining Allowance = 98% of Basic Salary. Write a program such that,
if the employee’s salary is input through the keyboard write a program to
find his Gross Salary.

Gross Salary = Basic Salary + Rental Allowance + Dining Allowance.

CODING:
Console.Write("Enter Employee Salary = ");
int salary = Convert.ToInt32(Console.ReadLine());
if (salary < 15000)
{
double rentalAllowance = Convert.ToDouble(salary * 0.1);
String RentalAllowance = "Rental Allowance = " + rentalAllowance;
double dinningAllowance = Convert.ToDouble(salary * 0.09);
String DinningAllowance = "Dinning Allowance = " + dinningAllowance;
String grossSalary = "Gross Salary = " + (salary + rentalAllowance +
dinningAllowance);
Console.WriteLine(RentalAllowance);
Console.WriteLine(DinningAllowance);
Console.WriteLine(grossSalary);

}
else if (salary >= 15000 && salary < 20000)
{
Console.Write("RentalAllowance = ");
const int rentalAllowance = 500;
double dinningAllowance = Convert.ToDouble(salary * 0.98);
String DinningAllowance = "Dinning Allowance = " + dinningAllowance;
String grossSalary = "Gross Salary = " + (salary + rentalAllowance +
dinningAllowance);
Console.WriteLine(rentalAllowance);
Console.WriteLine(DinningAllowance);
Console.WriteLine(grossSalary);

}
else
{
Console.WriteLine("Incorrect Salary");
}

Console.ReadLine();

CMD SCREENSHOT:

PROBLEM NO#09: Write a program that asks user to enter a number, your
program, then tells that number entered is one of these: positive even,
positive odd, negative even, negative odd or it’s a zero.

CODING:
Console.Write(" Enter Number = ");
int num = Convert.ToInt32(Console.ReadLine());
int num1 = num % 2;
if (num1 == 0 && num > 0)
{
Console.WriteLine("The Number is Positive Even. ");
}
else if (num1 != 0 && num > 0)
{
Console.WriteLine("The Number is Positive Odd. ");
}
else if (num1 == 0 && num < 0)
{
Console.WriteLine("The Number is Negative Even. ");
}
else if (num1 != 0 && num < 0)
{
Console.WriteLine("The Number is Negative Odd. ");
}
else
{
Console.WriteLine("The Number is Zero. ");
}

Console.ReadLine();

CMD SCREENSHOT:

PROBLEM NO#10: If the ages of Alpha, Bravo and Charlie are taken as input
from user, write a program that tell who is the youngest of them.

CODING:
Console.Write("Enter Age Of Alpha = ");
int a = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter Age Of Bravo = ");
int b = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter Age Of Charlie = ");
int c = Convert.ToInt32(Console.ReadLine());

if (a < b && a < c )


{
Console.WriteLine("Alpha Is Youngest");
}
else if (b < a && b < c)
{
Console.WriteLine("Bravo Is Youngest");
}
else if (c < a && c < a
)
{
Console.WriteLine("Charlie Is Youngest");
}

Console.ReadLine();

CMD SCREENSHOT:

PROBLEM NO#11: Daniel lives in Italy and travels to Mexico, India and New
Zealand. The times differences are:

Country Hours Minutes

Mexico -7 0

India +4 +30

New Zealand +11 0

Thus, if it is 10:15 in Italy it will be 14:45 in India.

Write a program which:

ulates the time in the country input using the data from the table

CODING:
Console.Write("Enter Name Of Country = ");
String country =Console.ReadLine();
Console.Write("Enter Time Of Italy = ");
Console.Write("Hours : ");
int H= Convert.ToInt32(Console.ReadLine());
Console.Write("Minutes :");
int M = Convert.ToInt32(Console.ReadLine());
if (country == "Mexico")
{
H -= 7;

}
else if (country == "India")
{
H += 4;
M += 30;

}
else if (country == "New Zealand")
{
H += 11;

if (H > 24)
{
H -= 24;

}
else if (M > 60)
{
M -= 60;
H++;
}
else
{
Console.Write("Countrry Is not Vlaid");
}

Console.Write("Time Is = {0}:{1} ", H, M);


Console.ReadLine();

CMD SCREENSHOT:

PROBLEM NO#12: Write a program that taken Gender, Years of services &
Qualification as input from user and show the salary as per the following
table.
Gender Years of Services Qualification Salary

Male Greater or equal to 05 MS or MBA PK Rs. 90,000

BS or MCS PK Rs. 60,000

Less than 05 BS or MCS PK Rs. 50,000

BBA PK Rs. 25,000

Female Greater of equal to 05 MBBS PK Rs. 75,000

BDS PK Rs. 60,000

Less than 05 MBBS PK Rs. 40,000

BDS PK Rs. 25,000

CODING:
Console.Write("Enter Gender = ");
string g = Console.ReadLine();
Console.Write("Enter Years Of Services = ");
int s = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter Qualification = ");
string q = Console.ReadLine();

if (g == "Male")
{
if (s >= 5)
{
if (q == "MS" || q == "MBA")
{
int salary = 90000;
Console.WriteLine("Employee Salary = " + salary);
}
else if (q == "BS" || q == "MCS")
{
int salary = 60000;
Console.WriteLine("Employee Salary = " + salary);
}
else if (s < 5)
{
if (q == "BS" || q == "MCS")
{
int salary = 50000;
Console.WriteLine("Employee Salary = " + salary);
}
else if (q == "BBA")
{
int salary = 25000;
Console.WriteLine("Employee Salary = " + salary);
}
}
}
}

else if (g == "Female")
{
if (s >= 5)
{
if (q == "MBBS")
{
int salary = 75000;
Console.WriteLine("Employee Salary = " + salary);
}
else if (q == "BDS")
{
int salary = 60000;
Console.WriteLine("Employee Salary = " + salary);
}
else if (s < 5)
{
if (q == "MBBS")
{
int salary = 40000;
Console.WriteLine("Employee Salary = " + salary);
}
else if (q == "BDS")
{
int salary = 25000;
Console.WriteLine("Employee Salary = " + salary);
}
}
}
}
else
{
Console.WriteLine("Invalid Data");
}

Console.ReadLine();

CMD SCREENSHOT:
PROBLEM NO#13: Suppose you are information officer in Admission
Department at PAF-KIET. Numbers of people come to you with several
questions regarding admission. Officers in Admission department came up
with a certain criteria as follows:

a) For Admission in College of Engineering 55% score required in student’s


high school examination but student must has background of engineering.

b) For admission in College of Computing & Information Science 50% score


required in high school and background should be of engineering or medical.

c) For Business Management minimum 45% score is required no previous


background is essential.

CODING:
Console.WriteLine(" Note: PLEASE ENTER FIRST WORD IN CAPITAL ");
Console.Write("Enter Precentage = ");
string prc = Console.ReadLine();
Console.Write("Enter Background = ");
string bck = Console.ReadLine();

if(prc == "55" && bck == "Pre Engg")


{
Console.WriteLine(" Admission In College of Engineering ");
}
else if(prc == "50" && (bck == "Pre Engg" || bck == "Pre Med"))
{
Console.WriteLine(" Admission In College of Computing & Information
Science ");
}
else if(prc == "45")
{
Console.WriteLine(" Admission In College of Business Management ");
}
else
{
Console.WriteLine("YOU ARE NOT APPLICABLE HERE");
}
Console.ReadLine();
CMD SCREENSHOT:

PROBLEM NO#14: Pakistan steel mills needs to implement a program that


will help their users to find the quality of the melted iron. They have
following 3 attributes:

(i) Hardness must be greater than 50

(ii) Carbon content must be less than 70%

(iii) Tensile strength must be greater than 56000

The quality benchmarks uses above attributes to label melted iron as


follows:

(a) Best quality if all of above conditions are met

(b) Good quality if conditions i and ii are met

(c) Average quality if conditions ii and iii are met

(d) Fair quality if any of the conditions are met

(e) Poor quality if none of them are met

CODING:
Console.Write("Hardness = ");
int h = Convert.ToInt32(Console.ReadLine());
Console.Write("Carbon Content = ");
int c = Convert.ToInt32(Console.ReadLine());
Console.Write("Tensile Strength = ");
int t = Convert.ToInt32(Console.ReadLine());

if( h > 50 && c < 70 && t > 56000 )


{
Console.WriteLine("Best Quality");
}
else if( h > 50 && c < 70 )
{
Console.WriteLine("Good Quality");
}
else if( c < 70 && t > 56000 )
{
Console.WriteLine("Average Quality");
}
else if( h > 50 || c < 70 || t > 56000)
{
Console.WriteLine("Fair Quality");
}
else
{
Console.WriteLine("Poor Quality");
}
Console.ReadLine();

CMD SCREENSHOT:

PROBLEM NO#15: Write a Program for Examination depart of your college.


Program should take these inputs Name, Roll No, Faculty, and All 4 Subjects
Marks. After that Clear the Console Screen & Print an eye-catching Mark
sheet. This is showing Name, Roll No, Faculty, All 4 Subjects Marks, Total
Marks, Percentage, Grade and Remarks.

Follow below criteria for Grade & Remarks

Percentage Grade Remarks

>= 87 A Excellent

78 - 86 B+ Good

72 – 77 B Good

66 – 71 C+ Not Good

60 – 65 C Not Good
<= 59 F Very Bad

(Note Use Switch Case for Remarks)

CODING:
Console.Write("Enter Student name = ");
string student = Console.ReadLine();

Console.Write("Enter Roll No = ");


int rollNo = Convert.ToInt32(Console.ReadLine());

Console.Write("Enter Facluty = ");


string faculty = Console.ReadLine();

Console.Write("Marks In PF = " );
int pf = Convert.ToInt32(Console.ReadLine());

Console.Write("Marks In IICT = ");


int iict = Convert.ToInt32(Console.ReadLine());

Console.Write("Marks In PIS = ");


int pis = Convert.ToInt32(Console.ReadLine());

Console.Write("Marks In VLM = ");


int vlm = Convert.ToInt32(Console.ReadLine());

const int totalMarks = 400;

int prc = (pf + iict + pis + vlm) * 100 / totalMarks;

Console.Clear();

Console.WriteLine(" STUDENT MARKS SHEET: ");

Console.WriteLine("Student name = {0} ", student);

Console.WriteLine("Roll No = {0} ", rollNo);

Console.WriteLine("Facluty = {0} ", faculty);

Console.WriteLine("Marks In PF = {0} ", pf);

Console.WriteLine("Marks In IICT = {0} ", iict);

Console.WriteLine("Marks In PIS = {0} ", pis);

Console.WriteLine("Marks In VLM = {0} ", vlm);

Console.WriteLine("Total Marks = {0} ", totalMarks);

Console.WriteLine("Percentage = {0} ", prc);

if (prc >= 87)


{
Console.Write("Grade = ");
char Grade = 'A';
Console.WriteLine(Grade);
switch (Grade)
{
case 'A':
Console.Write("Remarks = ");
string remarks = "Excellent";
Console.WriteLine(remarks);
break;
}
}
else if (prc >= 78 && prc <= 86)
{
Console.Write("Grade = ");
string Grade = "B+";
Console.WriteLine(Grade);
switch (Grade)
{
case "B+":
Console.Write("Remarks = ");
string remarks = "Fair";
Console.WriteLine(remarks);
break;
}
}
else if (prc >= 72 && prc <= 77)
{
Console.Write("Grade = ");
char Grade = 'B';
Console.WriteLine(Grade);
switch (Grade)
{
case 'B':
Console.Write("Remarks = ");
string remarks = "Good";
Console.WriteLine(remarks);
break;
}
}
else if (prc >= 66 && prc <= 71)
{
Console.Write("Grade = ");
string Grade = "C+";
Console.WriteLine(Grade);
switch (Grade)
{
case "C+":
Console.Write("Remarks = ");
string remarks = "Average";
Console.WriteLine(remarks);
break;
}
}
else if (prc >= 60 && prc <= 65)
{
Console.Write("Grade = ");
char Grade = 'C';
Console.WriteLine(Grade);
switch (Grade)
{
case 'C':
Console.Write("Remarks = ");
string remarks = "Not Good";
Console.WriteLine(remarks);
break;
}
}
else if (prc <= 59)
{
Console.Write("Grade = ");
char Grade = 'F';
Console.WriteLine(Grade);
switch (Grade)
{
case 'F':
Console.Write("Remarks = ");
string remarks = "Very Baad";
Console.WriteLine(remarks);
break;
}
}

Console.ReadLine();

CMD SCREENSHOT:

You might also like