PSCP Assignment
PSCP Assignment
#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
int ed,em,ey,ad,am,ay;
float fine=0;
cout<<"Enter the expected date of return of the book(dd/mm/yyyy): ";
cin>>ed>>em>>ey;
cout<<"Enter the actual date of return of the book(dd/mm/yyyy): ";
cin>>ad>>am>>ay;
if(ad<=ed)
cout<<"\nNO Dues";
else if(ad>ed&&am==em&&ay==ey)
{
fine=15*(ad-ed);
cout<<"\nFine = "<<fine;
}
else if(am>em&&ay==ey)
{
fine=50*(am-em);
cout<<"\nFine = "<<fine;
}
else if(ay>ey)
cout<<"\nFine = 1000";
getch();
}
OUTPUT:
PRGM-2)
#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
char c1,c2,c3,c4;
cout<<"Destination->HYD";
cout<<"\n1)Train(press 't')";
cout<<"\n2)Bus(press 'b')";
cout<<"\n3)Car(press 'c')";
cout<<"\nChoose Faculty position: ";
cin>>c1;
switch(c1)
{
case('b'):cout<<"BUS";
cout<<"\n1)Bike(press 'k')";
cout<<"\n2)Auto(press 'a')";
cout<<"\n**Got down at UPPAL**";
cout<<"\nChoose an option: ";
cin>>c2;
switch(c2)
{ case('k'):cout<<"\nDestination->HYD reached by bike";
break;
case('a'):cout<<"\nDestination->HYD reached by auto";
break; }
break;
case('c'):cout<<"CAR";
cout<<"\nDestination-HYD reached by Car ";
break;
case('t'):cout<<"TRAIN";
cout<<"\n1)Cab(press 'd')";
cout<<"\n2)Bike(press 'k')";
cout<<"\n3)Auto(press 'a')";
cout<<"\nChoose an option: ";
cin>>c3;
switch(c3)
{ case('b'):cout<<"\nDestination->HYD reached by Train and taking a bike";
break;
case('a'):cout<<"\nDestination->HYD reached by Train and taking an auto";
break;
case('d'): cout<<"You took Cab ";
cout<<"\nPress 'k' for bike to reach your destination: ";
cin>>c4;
switch(c4)
{ case('k'):cout<<"Destination->HYD reached by Train, cab and bike ";
break;
} break;
}
break;
}
getch();
}
OUTPUT:
PRGM-3)
#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
int a1,b1,a2,b2;
float sum,product;
char c;
cout<<"Enter fraction 1: ";
cin>>a1>>c>>b1;
cout<<"Enter fraction 2: ";
cin>>a2>>c>>b2;
sum=(a1*b2)+(a2*b1);
product=b1*b2;
cout<<"The sum of the 2 fractions = "<<sum<<c<<product;
getch();
}
OUTPUT:
PRGM-4)
#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
float f1,f2,m1,m2,f_used,km_t,mil;
cout<<"Enter the miles travelled at the start of the journey: ";
cin>>m1;
cout<<"Enter the miles travelled at the end of the journey: ";
cin>>m2;
cout<<"Enter the fuel consumed at the start of the journey: ";
cin>>f1;
cout<<"Enter the fuel consumed at the end of the journey: ";
cin>>f2;
f_used=f1-f2;
km_t=m1-m2;
mil=km_t/f_used;
cout<<"\nFuel used = "<<f_used;
cout<<"\nKilometers travelled(1mile=1.6kilometers) = "<<(1.6*km_t) ;
cout<<"\nOverall fuel consumed = "<<mil;
getch();
}
OUTPUT:
PRGM-5) OUTPUT:
#include <iostream.h>
#include <conio.h>
void main()
{ clrscr();
int x,price=0;
for(int i=1;i<50;i++)
{
x=i+50;
if(x%2==0&&x%3==0&&(x-3)%5==0)
price=0.5*x; }
cout<<"Number of eggs present were "<<price/0.5;
cout<<"\nMahesh paid Rs"<<price<<" to Sridhar ";
getch();
}
PRGM-6)
#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
int age;
float fare=0,dist;
cout<<"Enter the age of the passenger: ";
cin>>age;
cout<<"Enter the distance travelled from the source station to the destination: ";
cin>>dist;
if(age<5)
cout<<"\nChildren below 5 years are exempted from paying the fare" ;
else if(age>=5&&age<=59)
{
fare=0.5*dist;
cout<<"\nPassenger between 5-59 years of age need to pay full fare";
cout<<"\nFare = "<<fare;
}
else if(age>=60)
{
fare=0.6*0.5*dist;
cout<<"\nPassenger above 60 years of age(Senior Citizens) are exempted from paying 40% of the fare";
cout<<"\nFare = "<<fare;
}
getch();
}
OUTPUT:
PRGM-7)
#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
int bp;
cout<<"Enter the boiling point of the substance ";
cin>>bp;
switch(bp)
{
case 95 ... 105: cout<<"Water";
break;
OUTPUT:
PRGM-8)
#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
char type;
int hr;
cout<<"Motorbike(press 'm' or 'M')";
cout<<"\nCar(press 'c' or 'C')";
cout<<"\nBus(press 'b' or 'B')";
cout<<"\nSelect the type of vehicle: ";
cin>>type;
cout<<"Select the type of vehicle: ";
cin>>type;
cout<<"Enter the no of hours the vehicle spent in the parking lot: ";
cin>>hr;
switch(type)
{
case('M'):
case('m'):cout<<"Motorbike" ;
cout<<"\nParking charge =Rs"<<5*hr;
break;
case('C'):
case('c'):cout<<"Car" ;
cout<<"\nParking charge =Rs"<<10*hr;
break;
case('B'):
case('b'):cout<<"Bus" ;
cout<<"\nParking charge =Rs"<<50*hr;
break;
}
getch();
}
OUTPUT:
PRGM-9)
#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
float basic=0,da,hra,ma,ta,gross=0;
int type;
char g;
cout<<"\n1)Professor ";
cout<<"\n2)Associate Professor ";
cout<<"\n3)Assisstant Professor";
cout<<"\nSelect the type of faculty: ";
cin>>type;
switch(type)
{
case(1):cout<<"PROFESSOR ";
basic=40000;
da=0.55*basic;
hra=0.3*basic;
ma=0.1*basic;
ta=0.05*basic;
gross=basic+da+hra+ma;
cout<<"Gender(g/l): ";
cin>>g;
switch(g)
{
case('l'):cout<<"Lady faculty" ;
gross=gross+ta;
cout<<"\nGross Salary = "<<gross;
break;
case('g'):cout<<"Gent faculty ";
cout<<"\nGross Salary = "<<gross;
break;
}
break;
case(2):cout<<"ASSOCIATE PROFESSOR ";
basic=30000;
da=0.5*basic;
hra=0.25*basic;
ma=0.1*basic;
ta=0.05*basic;
gross=basic+da+hra+ma;
cout<<"Gender(g/l): ";
cin>>g;
switch(g)
{
case('l'):cout<<"Lady faculty" ;
gross=gross+ta;
cout<<"\nGross Salary = "<<gross;
break;
case('g'):cout<<"Gent faculty ";
cout<<"\nGross Salary = "<<gross;
break;
}
break;
gross=gross+ta;
cout<<"\nGross Salary = "<<gross;
break;
OUTPUT:
PRGM-10)
#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
float n;
cout<<"Enter the ritcher scale number: ";
cin>>n;
if(n<5.0)
cout<<"Little or no damage ";
else if(n>=5&&n<5.5)
cout<<"Some damage";
else if(n>=5.5&&n<6.5)
cout<<"Serious damage:walls may crack or fall ";
else if(n>=6.5&&n<7.5)
cout<<"Disaster:houses and buildings may collapse ";
else
cout<<"Catastrophe: most buildings destroyed";
getch();
}
OUTPUT: