Lab No. 6 Exercises: Using Using Using Using Namespace Class Static Void String

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

LAB NO.

6 EXERCISES
1. At IMTIAZ SUPER STORE, while purchasing certain items, customer gets a
discount of 10% only if the quantity of all purchased items is more than Rs. 5,000.
If Quantity and price per item are input through the keyboard, write a program to
calculate the total bill.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("\t\t\t=====================================");
Console.WriteLine("\t\t\t\tTo Find The Total Bill");
Console.WriteLine("\t\t\t=====================================");
Console.WriteLine("\a");
Console.WriteLine("\a");
int quantity,price, bill = 0;
Console.Write("\t\t\tEnter the quantity of the item: ");
quantity = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("\a");
Console.Write("\t\t\tEnter the price of the item: ");
price = Convert.ToInt32(Console.ReadLine());
bill = quantity * price;
Console.WriteLine("\a");
Console.Write("\t\t\tYour Bill Is= RS."+bill);
Console.WriteLine("\a");
Console.WriteLine("\a");

int totalbill=0;
if (bill > 5000)
{
totalbill = (bill / 100) * 10;
Console.WriteLine("\t\t\tYour Discounted Bill Is=RS." + totalbill);

}
else {
Console.Write("\t\t\tYour Total Bill Is=RS."+bill);
}

Console.ReadKey();
}
}
}
LAB NO. 6 EXERCISES

2. If Cost Price and Selling Price if an item is input through the keyboard, write a
program to that tells seller is at profit or loss? Further, it should ask user to enter
‘c’ if s/he wants to know how much profit or loss seller incurred.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{

Console.WriteLine("\t\t\t=============================================================");
Console.WriteLine("\t\t\t\tTo Tell Seller How Much He Has Profit Or Loss");

Console.WriteLine("\t\t\t=============================================================");
Console.WriteLine("\a");
int cp, sp;
Console.Write("\t\t\tEnter the Cost Price= RS.");
cp = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("\a");
Console.Write("\t\t\tEnter the Selling Price= RS.");
sp = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("\a");
int Total;
if(sp>cp){
Total = sp - cp;
Console.Write("\t\t\tYour Profit Is= RS."+Total);
}
else if(cp>sp){
Total =cp-sp;
Console.Write("\t\t\tYour Loss Is= RS."+Total);
}
else{
Console.Write("\t\t\tGot Neither Profit Nor Loss: ");
}
Console.ReadKey();
}
}
}
LAB NO. 6 EXERCISES

3. 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{

Console.WriteLine("\t\t\t============================");
Console.WriteLine("\t\t\t To find the Gross Salary");
Console.WriteLine("\t\t\t============================");
Console.WriteLine("\a");

int basicSalary,GrossSalary,RentalAllowance,DiningAllowance;
Console.Write("\t\t\t Enter the Basic Salary= Rs.");
basicSalary = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("\a");

if(basicSalary<15000){
RentalAllowance=(basicSalary/100)*10;
DiningAllowance = (basicSalary / 100) * 90;
GrossSalary = basicSalary + RentalAllowance + DiningAllowance;
Console.Write("\t\t\t Your Gross Salary= Rs."+GrossSalary);

}
else if (basicSalary >= 15000 && basicSalary < 20000)
{
DiningAllowance = (basicSalary / 100) * 98;
RentalAllowance = 500;
GrossSalary = basicSalary + RentalAllowance + DiningAllowance;
Console.Write("\t\t\t Your Gross Salary= Rs." + GrossSalary);
}
else {
Console.Write("\t\t\t Salary Is Above 20000");
}
Console.ReadKey();
}
}
}
LAB NO. 6 EXERCISES

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

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("\t\t\t==============================");
Console.WriteLine("\t\t\t\tLibrary Charges");
Console.WriteLine("\t\t\t==============================");
Console.WriteLine("\a");
int days, fine;
Console.Write("\t\t\tEnter The Number Of Days: ");
days = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("\a");

if(days>0 && days<=5){


fine = 50;
Console.Write("\t\t\tYour Fine Is: "+fine);
}
else if (days>=6 && days<=10){
fine = 100;
Console.Write("\t\t\tYour Fine Is: "+fine);
}
else if(days>10 && days<=30){
fine = 150;
Console.Write("\t\t\tYour Fine Is: "+fine);
}
else if (days > 30)
{
Console.Write("\t\t\tYour membership is cancelled");
}
else {

Console.ReadKey();
}
}
}
LAB NO. 6 EXERCISES
5. Team nascent innovations is a software house that insures its software developers in the
following cases:
If the software developer is married.
If the software developer is unmarried, male & above 28 years of age.
If the software developer is unmarried, female & above 22 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.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{

Console.WriteLine("\t\t\t================================================================
=====");
Console.WriteLine("\t\t\t To Determine whether the software developer is to
be insured or not");

Console.WriteLine("\t\t\t================================================================
=====");
Console.WriteLine("\a");
int status, age;
string gender;
Console.Write("\t\t\tEnter Your Martial status (1 for Married, 2 for
Unmarried): ");
status = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("\a");
Console.Write("\t\t\tEnter Your age: ");
age = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("\a");
Console.Write("\t\t\tEnter Your Gender (M for male, F for female): ");
gender = Console.ReadLine();
Console.WriteLine("\a");

if(status==1 ){
Console.WriteLine("\t\t\tCongratulations.You are insured");
}
else if(status==2 && gender=="M" && age>=28){
Console.WriteLine("\t\t\tCongratulation.You are insured");
}
else if (status == 2 && gender == "F" && age >= 22)
{
Console.WriteLine("\t\t\tCongratulation.You are insured");
}
else {
Console.WriteLine("\t\t\tSorry.You are not insured");
}
LAB NO. 6 EXERCISES
Console.ReadKey();
}
}
}

You might also like