ASSIGNMENT 3

PROGRAMMING
FUNDAMENTALS
COURSE ID: 90962
STUDENT ID: 7663

Linq. System.Write("Enter the unit price of the item: "). Console. Console. namespace Question1 { class Program { static void Main(string[] args) { int quantity. SOURCE CODE: using using using using using System. Console.QUESTION 1: At Imtiaz Super Store. bill).Threading. quantity = Convert.ReadLine()).ReadLine()).ToDouble(Console. bill.Write("Enter the quantity of the item purchased: "). System. If quantity and price per item are input through the keyboard. while purchasing certain items. unit = Convert.ToInt32(Console.Collections. customer gets a discount of 10% only if the quantity of purchased items is more than Rs. System. double unit.Generic. bill). if (bill > 5000) { bill = (bill / 100) * 10.WriteLine("The bill is {0}".Text. Console.Tasks. } } } } .WriteLine("The discounted bill is {0}". write a program to calculate the total bill. bill = quantity * unit. 5000. System.

} } } } . 15.WriteLine("The gross salary is {0}".Collections. diningAllowance. basic = Convert.Linq. Console. then Home Rental Allowance = 10% of basic salary and Dining Allowance = 90% of basic salary. System. 20. homeAllowance.Question 02: In a company an employee is paid as under: If his basic salary is less than Rs.000 then Home Rental Allowance = Rs.WriteLine("The gross salary is {0}". homeAllowance). Console.WriteLine("Your Home Rental Allowance is {0}". gross = basic + homeAllowance + diningAllowance. diningAllowance). gross. 15. If the employee’s salary is input through the keyboard write a program to find his gross salary. If his salary is either equal to or above Rs. } else if (basic >= 15000 && basic < 20000) { homeAllowance = 500.ToDouble(Console.WriteLine("Your Dining Allowance is {0}". System. namespace Question2 { class Program { static void Main(string[] args) { double basic. Gross Salary = Basic Salary + Home Rental Allowance + Dining Allowance SOURCE CODE: using using using using using System. diningAllowance). gross). homeAllowance). gross). Console. Console.Generic.000 but less than Rs. diningAllowance = (basic / 100) * 98.Threading. diningAllowance = (basic / 100) * 90.ReadLine()).WriteLine("Your Dining Allowance is {0}". gross = basic + homeAllowance + diningAllowance.Tasks.WriteLine("Your Home Rental Allowance is {0}".Write("Enter your basic salary: "). if (basic < 15000) { homeAllowance = (basic / 100) * 10. Console.Text.000. System. Console. Console. System. 500 and Dining Allowance = 98% of basic salary.

Tasks. status = Convert.Linq. } else { Console.ToInt32(Console. age = Convert. } .Text. You are insured. if (status == 1) { Console.Collections. age.Threading. char gender. System. } else if (gender == 'M' && age == 28) { Console.ReadLine()).").WriteLine("Congratulations. male & above 28 years of age. Console.ReadLine()).ToInt32(Console. You are insured.ToChar(Console. gender and age of the software developer are user defined. F for Female): ")."). SOURCE CODE: using using using using using System.  If the software developer is unmarried. System.").WriteLine("Sorry. In all other cases. If he marital status.").ReadLine()).WriteLine("Please enter your gender(M for Male.  If the software developer is unmarried. the software developer is not insured.WriteLine("Congratulations. Console.WriteLine("Congratulations. gender = Convert. write a program to determine whether the software developer is to be insured or not.Write("Please enter your marital status(1 for Married. 2 for Unmarried): "). female & above 22 years of age. You are insured.Write("Please enter your age: "). The company will not pay for your insurance. namespace Question3 { class Program { static void Main(string[] args) { int status. } else if (gender == 'F' && age == 22) { Console.Question 03: Team Nascent Innovations is a software house that insures its software developers in the following cases:  If the software developer is married. Console. System.Generic. System.

} } } .

positive odd. namespace Question4 { class Program { static void Main(string[] args) { int number. number = Convert. System.Text. then tells that is one of these: positive even.Linq. System.Tasks. } else if (number < 0 && number %2 == 0) { Console."). your program.Generic.WriteLine("Negative Even. } else if (number < 0 && number %2 != 0) { Console. } } } } .ToInt32(Console. odd. System.WriteLine("\tProgram to check whether a number is even. SOURCE CODE: using using using using using System. negative odd or it’s a ZERO.WriteLine("Positive Odd.WriteLine("Positive Even. System."). } else { Console.Threading.Write("Enter the number: ").WriteLine("Negative Odd. if (number >= 1 && number % 2== 0) { Console.ReadLine()). negative even \n\t\t\tnegative odd or zero\n\n"). negative even."). } else if (number >= 1 && number %2 != 0) { Console.Collections. Console.").").WriteLine("The number is zero.Question 04: Write a program that asks user to enter a number. Console.

ReadLine()).ReadLine().WriteLine("Your salary is 90. gender = Convert.Question 05: Write a program to calculate the salary as per the following table: Gender Male Female Years of Service Greater or equals to 05 Greater or equals to 05 Less than 05 Qualification MS or MBA BS or MCS BS or MCS Salary 90.Write("Please enter your years of service: "). System. years = Convert.ReadLine()).Collections.Tasks.000 50.000").000 80. System.Write("Please enter your qualification: ").ToChar(Console. int years.000 SOURCE CODE: using using using using using System. System. Console.Write("Please enter your gender: ").000 40. } else if (gender== 'M' && (qualification== "BS" || qualification == "MCS") && years >= 5) { Console.Generic.WriteLine("Your salary is 60.000 Less than 05 BBA 20.WriteLine("For MS. MCS and MBA.ToInt32(Console.Text. Console. Console. Console. namespace Question5 { class Program { static void Main(string[] args) { char gender.000 Greater or equals to 05 Less than 05 BS or MCS BS or MCS 55.Threading. string qualification. if (gender=='M' && (qualification== "MS" || qualification== "MBA") && years >= 5) { Console. years of Service must always be greater or equal to 5\n\n\n").000 60. qualification = Console.000"). System. } else if (gender == 'M' && (qualification == "BS" || qualification == "MCS") && years < 5) .Linq.000 Less than 05 Greater or equals to 05 BBA MS or MBA 25.

000").WriteLine("Your salary is 50.000").000").WriteLine("Your salary is 55. } else if (gender=='F' && (qualification== "MS" || qualification== "MBA") && years >= 5) { Console.WriteLine("Your salary is 40. } .WriteLine("Your salary is 20.000"). } if (gender=='F' && (qualification== "BS" || qualification== "MCS") && years >= 5) { Console.{ } } } Console. } else if (gender == 'F' && (qualification == "BS" || qualification == "MCS") && years < 5) { Console.WriteLine("Your salary is 80.000"). } if (gender=='F' && qualification== "BBA" && years > 5) { Console.000"). } if (gender=='M' && qualification== "BBA" && years >= 5) { Console.WriteLine("Your salary is 25.

selling = Convert. char choice = Convert.WriteLine("\nPlease press C if you wish to find out how much loss incurred "). System. if (choice == 'C' || choice == 'c') { Console. char choice = Convert.ReadLine()).Threading. it should ask user to enter ‘C’ if s/he wants to know how much profit or lost seller incurred.Write("Please enter the selling price of the object: "). if (selling > cost) { Console. selling.Tasks.WriteLine("\nPlease press C if you wish to find out how much profit incurred "). } } else { Console.WriteLine("\nThe seller is at loss. } } } } } .ReadLine()). namespace Question6 { class Program { static void Main(string[] args) { double cost.").Question 06: If cost price and selling price of an item is input through the keyboard.Collections.ToChar(Console.ToDouble(Console.ReadLine()). SOURCE CODE: using using using using using System.Text.Linq.Write("Please enter the cost price of the object: ").ReadLine()).WriteLine("\nThe profit is {0}". write a program to that tells seller is at profit or loss? Further. System. Console. (selling-cost)). System. if (choice == 'C' || choice == 'c') { Console.WriteLine("\nThe seller is at profit.WriteLine("\nThe profit is {0}". (cost-selling)).ToChar(Console.ToDouble(Console. cost = Convert. Console. Console. Console. System.Generic.").

bravo.").").Tasks.ReadLine())."). System. } if (alpha == bravo && alpha == charlie) { Console. Console. alpha = Convert. System. System. bravo = Convert.Generic. if (alpha > bravo && alpha > charlie) { Console. SOURCE CODE: using using using using using System.WriteLine("Charlie is the eldest."). charlie. } if (charlie > alpha && charlie > bravo) { Console. charlie = Convert.Collections. Console.Threading.ToInt32(Console. namespace Question7 { class Program { static void Main(string[] args) { int alpha.ToInt32(Console.ToInt32(Console.ReadLine()).Write("Enter the age of charlie: ").Text. Console.ReadLine()).WriteLine("Alpha is the eldest. write a program that tell who is the youngest of them.WriteLine("They are all the same age. System. } } } } .Write("Enter the age of bravo: ").Linq.WriteLine("Bravo is the eldest. } if (bravo > alpha && bravo > charlie) { Console.Question 07: If the ages of Alpha.Write("Enter the age of alpha: "). Bravo and Charlie are taken as input from user.

ToInt32(Console. y_cor = Convert.").Text. y_cor.WriteLine("\nThe point doesnt lie on x axis.Write("Enter the x coordinate of the point: ").WriteLine("\nThe point lies on x-axis").Tasks. namespace Question8 { class Program { static void Main(string[] args) { int x_cor.Generic. x_cor = Convert.Linq. } if (x_cor == 0 && y_cor >= 1) { Console. y-axis or on the origin (0.WriteLine("\nThe point lies on the origin.Threading.WriteLine("\nThe point lies on y-axis"). System. } } } } . Console.Collections.Write("\nEnter the y coordinate of the point: "). Your program has to tell whether the given point is on x-axis.ToInt32(Console. System. y axis or origin"). } if (x_cor >= 1 && y_cor >= 1) { Console.ReadLine()).ReadLine()).0) SOURCE CODE: using using using using using System. System. Console. } if (x_cor == 0 && y_cor == 0) { Console. if (x_cor >= 1 && y_cor == 0) { Console. System.Question 08: Write a program that will take x and y coordinates of a point from user.

y2 = Convert.x1). double x2.Pow((y2 . y = -1. x2 = Convert. Now write a program that will ask user to enter radius R of circle and coordinates of another point P2. double y2.ReadLine()). 2) + Math. } if (test > newradius) { Console. y1= -1.Write("\nY coordinate: ").").Generic.Collections.Threading.ToDouble(Console. Console.WriteLine("\nThe point lies outside the circle.ToDouble(Console.WriteLine("\nThe point lies inside the circle. System. Console. double radius. Console. double test = Math."). System.y1). System.Tasks.Linq.Pow((x2 .Write("Please enter the radius of the circle: "). SOURCE CODE: using using using using using System. radius = Convert. double newradius= radius*radius. if (test == newradius) { Console. } { } } } } .ReadLine()).WriteLine("\n\nPlease enter the coordinates of the second circle\n"). Then your program has to tell whether the point lies inside the circle or outside.ToDouble(Console. 2).Question 09: Suppose the center of the circle is at point P1 whose coordinates is x = 19. Console.ReadLine()).Write("\nX coordinate: ").Text. System. namespace Question9 { class Program { static void Main(string[] args) { double x1= 19.

System.ToInt32(Console.Tasks. if (hardness > 50 && carbon < 70 && tensile > 56000) { Console. carbon. hardness = Convert. carbon = Convert. System. System.Write("Enter the carbon content of the iron: ").Threading. } else if (hardness > 50 && carbon < 70 && tensile < 56000) { Console. System. They have following 3 criteria: 1 Hardness must be greater than 50 2 Carbon content must be less than 70% 3 Tensile strength must be greater than 56000 The quality benchmarks are as follows:      Best quality if all of above conditions are met Good quality if conditions 1 and 2 are met Average quality if conditions 2 and 3 are met Fair quality if any of the conditions are met Poor quality if none of them are met SOURCE CODE: using using using using using System.Write("Enter the tensile strength of the iron: ").ReadLine()).Collections.ReadLine()). } else if (hardness < 50 && carbon <70 && tensile > 56000) { Console. } else if (hardness > 50 || carbon < 70 || tensile > 56000) . Console. tensile. Console.WriteLine("Average quality"). tensile = Convert.ToInt32(Console.ToInt32(Console.Linq. Console.ReadLine()).Generic.Text.Question 10:Pakistan Steel Mills needs to implement a program that will help their users to find the quality of the melted iron.WriteLine("Good quality")."). namespace Question10 { class Program { static void Main(string[] args) { int hardness.Write("Enter the hardness of the melted iron: ").WriteLine("Best quality.

} . } else { Console.WriteLine("Poor quality").WriteLine("Fair quality").{ } } } Console.