Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i want ot write a program for calculating challan for traffic violations. The basic idea is that user will enter the type of violation and number of days passed till date of challan. The challan calculator will calculate the challan based upon the type of violation and number of days.

Detailed Description:

 i are required to take input from user for type of traffic violation.
 User will enter ‘1’ if the violation type is “For breaking traffic signal”
 User will enter ‘2’ if the violation type is “For over speeding”
 User will enter ‘3’ if the violation type is “For not wearing seat belt”
 If user enters any other number except 1, 2 or 3, the program will print a message “Enter a valid type of traffic violation”.
 After printing this message program will start again from beginning and prompt user to enter the valid type of traffic violation.
 If user enters ‘1’ the amount of fine is Rs.500, if ‘2’ then Rs.300 and if user enters ‘3’ then fine will be Rs.200.

 Now, program will prompt user to enter number of days passed till challan date.
 If number of days are less than or equal to 10, then the total challan will be same as amount of fine.
 If number of days are more than 10 or less than/equal to 30, then total challan will be double of amount of fine.
 If number of days are more than 30, then 50% of fine will be added in double of amount of fine. i.e. 2 times fine + 1/2 times fine.

 After displaying the total challan to user, the program should ask if the user wants to calculate another challan. The user can enter ‘y’ or ‘n’ as choices for yes or no. Program will handle user’s choice in both upper and lower cases.

 If the user enters ‘y’ or ‘Y’, then program should clear the screen and start the whole process again or terminate the program otherwise.
what codes should i write to take these results.
Posted
Updated 13-Apr-12 1:03am
v2
Comments
nagendrathecoder 13-Apr-12 7:03am    
What have you tried so far?
Mohibur Rashid 29-Apr-12 7:04am    
I don't get it how come challan means fine? challan can be delivery but not fine
Sandeep Mewara 29-Apr-12 10:15am    
No. No one will give you code.

Here is what is expected of enquirers:
1. TRY first what you want to do!
2. Formulate what was done by you that looks like an issue/not working.

Try them and tell if you face issues.
Members will be more than happy to help like this.
Muhammad Shahid Farooq 1-May-12 10:30am    
Reason for my vote of 1
Home Work

please read this[^]
 
Share this answer
 
Comments
JackDingler 13-Apr-12 16:24pm    
My 5.
Nelek 14-Apr-12 6:17am    
Thanks
stib_markc 30-Apr-12 7:26am    
5
You should try yourself to do your own homework.
Please note this is a very simple task, if you won't eventually succeed, then you'll could be a great Project Manager.
 
Share this answer
 
Comments
JackDingler 13-Apr-12 16:25pm    
LOL. :)
stib_markc 30-Apr-12 7:26am    
lmao
Rather posting home work questions, post what are all the things you tried to solve it. And then ask the regarding questions. I hope nobody will do your homework for free.
 
Share this answer
 
//Header files
#include <iostream.h> //this header file is included to use cout and cin
#include <cstdlib> //this header file is included to use clearing screen function


//Main function
void main(void)
{//Start of main function

//Variable declaration
int violationType; //this varaible is used in switch statement for violation type
int fineAmount; //this variable is used in each case for amount of fine
int challanDays; //this varaible is used in each case for days passed to challan
char choice; //this varaible is used in do-while loop for choice to calculate next challan

do
{ //Start of do-while loop

//Clearing Screen
system("cls");

//Show output
cout<<"******* CHALLAN CALCULATOR FOR TRAFFIC VIOLATIONS ******* \n\n";
cout<<"Enter 1 for breaking traffic signal \n";
cout<<"Enter 2 for over speeding \n";
cout<<"Enter 3 for not wearing seat belt \n";
cout<<"\nEnter the type of traffic voilation (1,2 or 3): ";

//Input for traffic violation
cin>>violationType;

switch(violationType)
{ //Start of switch

case 1:
fineAmount = 500;
cout<<"\nEnter number of days passed till challan date: ";
cin>>challanDays;

if (challanDays <= 10)
{
cout<<"\nTotal amount of challan is Rs."<<fineAmount;
}
else if (challanDays > 10 && challanDays <=30)
{
cout<<"\nTotal amount of challan is Rs."<<fineAmount * 2;
}
else
{
cout<<"\nTotal amount of challan is Rs."<<fineAmount * 2.5;
}
break;

case 2:
fineAmount = 300;
cout<<"\nEnter number of days passed till challan date: ";
cin>>challanDays;

if (challanDays <= 10)
{
cout<<"\nTotal amount of challan is Rs."<<fineAmount;
}
else if (challanDays > 10 && challanDays <=30)
{
cout<<"\nTotal amount of challan is Rs."<<fineAmount * 2;
}
else
{
cout<<"\nTotal amount of challan is Rs."<<fineAmount * 2.5;
}
break;

case 3:
fineAmount = 200;
cout<<"\nEnter number of days passed till challan date: ";
cin>>challanDays;

if (challanDays <= 10)
{
cout<<"\nTotal amount of challan is Rs."<<fineAmount;
}
else if (challanDays > 10 && challanDays <=30)
{
cout<<"\nTotal amount of challan is Rs."<<fineAmount * 2;
}
else
{
cout<<"\nTotal amount of challan is Rs."<<fineAmount * 2.5;
}
break;

//Default case when user will entered wrong value
default:
cout<<"\nEnter a valid type of traffic violation";
break;
} //End of switch

cout<<"\n\nDo you want to calculate another challan (y/n): ";
cin>> choice;

} //end of do-while loop
while (choice == 'y' || choice == 'Y');

}//End of main function
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900