0% found this document useful (0 votes)
60 views9 pages

Ahmed CP Assignment#2

The document contains code for 5 programming tasks: 1) A program to calculate employee salary based on grade using a switch statement 2) A program to multiply two arrays and store the result in a third array 3) A program to calculate monthly loan installments and total amount paying considering insurance and markup 4) An algorithm to generate a total automobile shop bill calculating different charges 5) A program to generate output with chapters and sections in numbered format

Uploaded by

Hunain gujjar
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)
60 views9 pages

Ahmed CP Assignment#2

The document contains code for 5 programming tasks: 1) A program to calculate employee salary based on grade using a switch statement 2) A program to multiply two arrays and store the result in a third array 3) A program to calculate monthly loan installments and total amount paying considering insurance and markup 4) An algorithm to generate a total automobile shop bill calculating different charges 5) A program to generate output with chapters and sections in numbered format

Uploaded by

Hunain gujjar
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/ 9

NAME: AHMED YOUNAS COMPUTER PROGRAMING ENROLL#:02-131222-115

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:
{

HRA = 0.02 * BS;


MA = 0.025 * BS;
VMA = 0.01 * BS;
PF = 0.075 * BS;
SAL = BS + HRA + MA + VMA - PF;
Console.WriteLine("Mr {0} your salary is: {1}.", name, SAL);

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:
{

HRA = 0.06 * BS;


MA = 0.033 * 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;
}
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;

Console.Write("Enter row for matrix 1: ");

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.Write("Enter col for matrix 2: ");


c1 = Convert.ToInt32(Console.ReadLine());

int[,] ma1 = new int[r, c];


Console.WriteLine();
Console.WriteLine("ELEMENTS OF MATRICS 1:");
if (c == r1) //this condition is neccesaary because its follow the marics multipication rule
{

for (int i = 0; i < r; i++)


{
for (int j = 0; j < c; j++)
{
Console.Write("Element [{0},{1}]: ", i, j);
ma1[i, j] = Convert.ToInt32(Console.ReadLine());
}
}
Console.WriteLine();
Console.WriteLine("Matrix 1:");
for (int i = 0; i < r; i++)
{
Console.WriteLine();
for (int j = 0; j < c; j++)
{
Console.Write("{0}\t", ma1[i, j]);
NAME: AHMED YOUNAS COMPUTER PROGRAMING ENROLL#:02-131222-115

}
}
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++)
{

for (int j = 0; j < c1; j++)


{
result[i, j] = 0;
for (int k = 0; k < r1; k++)
{
result[i, j] = result[i, j] + ma1[i, k] * ma2[k, j];

}
}
}
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.

6) Display the bill.

7) End.
NAME: AHMED YOUNAS COMPUTER PROGRAMING ENROLL#:02-131222-115

5. write a program that will generate the following output

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();

for (int j = 1; j <6; j++)


{
if (i == 1)
{ Console.WriteLine("\tSECTION 1." + j); }
if (i == 2)
{ Console.WriteLine("\tSECTION 2." + j); }

if (i == 3)
{ Console.WriteLine("\tSECTION 3." + j); }
}
Console.WriteLine();

Console.ReadLine();

}
}
}
}

OUTPUT:
NAME: AHMED YOUNAS COMPUTER PROGRAMING ENROLL#:02-131222-115

You might also like