Ahmed CP Assignment#2
Ahmed CP Assignment#2
1. Write a program that will use switch statement and calculate the salary of an employee, on the bases
of following table and formulae and display the calculated salary along with his provided name
TASK 1:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace ahmed_assignment
{
internal class Program
{
static void Main(string[] args)
{
string name;
double BS,HRA,MA,VMA,PF,SAL=0;
int g;
Console.WriteLine("=====SALARY CALCULATION====");
Console.WriteLine("PLEASE ENTER YOUR NAME:");
name = Console.ReadLine();
Console.WriteLine("PLEASE ENTER YOUR BASIC SALARY:");
BS=double.Parse(Console.ReadLine());
Console.WriteLine("PLEASE ENTER YOUR GRADE:");
g=int.Parse(Console.ReadLine());
switch (g)
{
case 17:
{
break;
}
case 18:
{
HRA = 0.055 * BS;
MA = 0.03 * BS;
VMA = 0.015 * BS;
PF = 0.075 * BS;
SAL = BS + HRA + MA + VMA - PF;
Console.WriteLine("Mr {0} your salary is: {1}.", name, SAL);
break;
}
NAME: AHMED YOUNAS COMPUTER PROGRAMING ENROLL#:02-131222-115
case 19:
{
break;
}
default:
{
Console.WriteLine("enter the correct grade");
break;
}
}
Console.ReadLine();
}
}
}
OUTPUT:
NAME: AHMED YOUNAS COMPUTER PROGRAMING ENROLL#:02-131222-115
TASK 2:
2. Multiply Array1 with Array2 and stores its result in Array3. Apply matrix rules for multiplication [RowN
* ColN]. [Using loop]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace ahmed_assignment
{
internal class Program
{
static void Main(string[] args)
{
int r, r1, c, c1;
r = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter col for matrix 1: ");
c = Convert.ToInt32(Console.ReadLine());
Console.WriteLine();
Console.Write("Enter row for matrix 2: ");
r1 = Convert.ToInt32(Console.ReadLine());
}
}
Console.WriteLine();
Console.WriteLine("ELEMENTS OF MATRICS 2:");
int[,] ma2 = new int[r, c];
for (int i = 0; i < r1; i++)
{
for (int j = 0; j < c1; j++)
{
Console.Write("Element {0},{1}:", i, j);
ma2[i, j] = int.Parse(Console.ReadLine());
}
}
Console.WriteLine();
Console.WriteLine("MAtrix 2:");
for (int i = 0; i < r1; i++)
{
Console.WriteLine();
for (int j = 0; j < c1; j++)
{
Console.Write("{0}\t", ma2[i, j]);
}
}
Console.WriteLine();
int[,] result = new int[50, 50];
Console.WriteLine();
for (int i = 0; i < r; i++)
{
}
}
}
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("MULTIPLICATION RESULT:");
for (int i = 0; i < r; i++)
{
Console.WriteLine();
for (int j = 0; j < c1; j++)
{
Console.Write("{0}\t", result[i, j]);
}
}
}
else
{
Console.WriteLine("as the number of colounm 1 in matrix 1 is not equal to no of row in matrix 2, so the
calcultion of matrix is not possible ");
}
NAME: AHMED YOUNAS COMPUTER PROGRAMING ENROLL#:02-131222-115
Console.ReadLine();
}
}
}
OUTPUT:
TASK 3:
3. Write a program that will generate the monthly installment and total amount to be paid of personal
loan where the insurance is 2% and mark up is 18% per year, initial processing fee is 3%
NAME: AHMED YOUNAS COMPUTER PROGRAMING ENROLL#:02-131222-115
CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace ahmed_assignment
{
internal class Program
{
static void Main(string[] args)
{
double AM, time, DP, ins, mu, MI, totalamt = 0;
Console.WriteLine(" PLEASE ENTER THE LOAN AMOUNT: ");
AM = double.Parse(Console.ReadLine());
Console.WriteLine("PLEASE ENTER THE DURATION IN YEARS:");
time = double.Parse(Console.ReadLine());
DP = AM * (0.03);
ins = AM * (0.02);
mu = AM * (0.18) * time;
totalamt = (AM + ins + mu) - DP;
MI = totalamt / (time * 12);//FOR MONTHS
Console.WriteLine("Your intial processing fee on the loan is:" + DP);//DOWN PAYMENT FIRST PAYMENT
Console.WriteLine("The Insurance on Loan is:\t\t " + ins);
Console.WriteLine("Your Mark up on amount :\t\t" + mu);
Console.WriteLine("Your Total loan to be paid:\t\t " + totalamt);
Console.WriteLine("Your Monthly Installement is:\t\t"+ MI);
Console.ReadLine();
}
}
}
OUTPUT:
NAME: AHMED YOUNAS COMPUTER PROGRAMING ENROLL#:02-131222-115
TASK 4:
4. Write an Algorithm to generate total bill of an automobile shop, where the bill is divided into
mechanical charges, vehicle parts charges, Auto wash charges and other charges for a customer if the
total bill of mechanical charges and vehicle parts charges is over Rs. 10,000/- then the customer will get
complementary car wash and car wash charges will be removed from the bill.
ALGORITHUM:
1) START.
2) Read values of Mechanical Charges, Parts Charges, Wash Charges and Other Auto Charges.
3) Take Sum of Mechanical Charges and Parts Charges.
4) If (Sum>1000): Remove or subtract the Car Wash Charges from bill, if he did not take service of
Car Wash, then give him car wash service as a compulsory .
5) If (Sum<=1000): then he will pay his complete bill without any discount and Car Wash.
7) End.
NAME: AHMED YOUNAS COMPUTER PROGRAMING ENROLL#:02-131222-115
TASK 5:
CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace ahmed_assignment
{
internal class Program
{
static void Main(string[] args)
{
for (int i = 1; i <= 3; i++)
{
Console.WriteLine("CHAPTER " + i);
Console.WriteLine();
if (i == 3)
{ Console.WriteLine("\tSECTION 3." + j); }
}
Console.WriteLine();
Console.ReadLine();
}
}
}
}
OUTPUT:
NAME: AHMED YOUNAS COMPUTER PROGRAMING ENROLL#:02-131222-115