Saturday 21 July 2012

Assignment_of_CS201

#include<iostream.h>
#include<conio.h>

main()

{
char i;
int a, b;

do
{
system("cls");
cout<<"******Challan Calculator for Traffic Violations******";
cout<<endl;
cout<<endl;
cout<<"Enter '1' for Breaking Signal:";
cout<<endl;
cout<<"Enter '2' for Over Speed:";
cout<<endl;
cout<<"Enter '3' for Wearing not Seat Belt:";
cout<<endl;
cout<<endl;
cout<<"Enter the type of traffic violation 1, 2 or 3:";
cin>>a;
cout<<endl;
switch(a)
{
case 1:
cout<<"Enter the numbers of days passed till challan date:";
cin>>b;
cout<<endl;

if(b<=10)cout<<"The total fine is Rs: "<<500;
else if (b<=30)cout<<"The total fine is Rs: "<<500*2;
else if (b>30)cout<<"The total fine is Rs: "<<(500*2)+(500/2);
break;
case 2:
cout<<"Enter the numbers of days passed till challan date:";
cin>>b;
cout<<endl;

if(b<=10)cout<<"The total fine is Rs: "<<300;
else if (b<=30)cout<<"The total fine is Rs: "<<300*2;
else if (b>30)cout<<"The total fine is Rs: "<<(300*2)+(300/2);

break;
case 3:
cout<<"Enter the numbers of days passed till challan date:";
cin>>b;
cout<<endl;

if(b<=10)cout<<"The total fine is Rs: "<<200;
else if (b<=30)cout<<"The total fine is Rs: "<<200*2;
else if (b>30)cout<<"The total fine is Rs: "<<(200*2)+(200/2);
break;
default:
cout<<endl;
cout<<endl;
cout<<"Please Enter a Valid Type of Traffic Violation:";
cout<<endl;
cout<<endl;
getch();
cout<<endl;
cout<<endl;
system("cls");
main();
break;

}

cout<<endl;
cout<<endl;
cout<<"Do you want another challan calculation? (y/n):";
cin>>i;
}
while(i != 'N' && i != 'n' );

}