Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.


CS201 Assignment No 1 Solution Spring 2012

See the below attached file please

ASI%20SOL.cpp

Views: 2928

Attachments:

Replies to This Discussion

CS201 Perfect Solution of 1st Assignment spring 2012.


#include<iostream.h>
main(){

int choice, days, fine;
char op;
cout"**********************************************"endl;
cout" Challan Calculator for Traffic Violation "endl;
cout"**********************************************"endl;
while(1){
coutendl;
cout" Enter '1' for breaking signals"endl;
cout" Enter '2' for over Speeding"endl;
cout" Enter '3' for not wearing seat belt"endl;
coutendl;
cout"Enter a type of traffic violation(1 , 2 , 3) :";
cin>>choice;

if(choice == 1 || choice == 2 || choice == 3){

switch(choice){

case 1:
cout"Enter the number of days passed till challan date :";
cin>>days;
if(days <= 10){
coutendl;
cout"The Total Challan is : "500" Rs"endl;
}else
if(days > 10 && days<=30){
coutendl;
cout"The Total Challan is : "500*2" Rs"endl;
}else{
coutendl;
cout"The Total Challan is : "500*2+((500*2)/2.0)" Rs"endl;
}
break;

case 2:
cout"Enter the number of days passed till challan date :";
cin>>days;
if(days <= 10){
coutendl;
cout"The Total Challan is : "300" Rs"endl;
}else
if(days > 10 && days<=30){
coutendl;
cout"The Total Challan is : "300*2" Rs"endl;
}else{
coutendl;
cout"The Total Challan is : "300*2+((300*2)/2.0)" Rs"endl;
}
break;
case 3:
cout"Enter the number of days passed till challan date :";
cin>>days;
if(days <= 10){
coutendl; 
cout"The Total Challan is : "200" Rs"endl;
}else
if(days > 10 && days<=30){
coutendl;
cout"The Total Challan is : "200*2" Rs"endl;
}else{
coutendl;
cout"The Total Challan is : "200*2+((200*2)/2.0)" Rs"endl;
}
}


}else{
cout"Enter a valid type of traffic violation"endl;
}
coutendl;
cout"Do you want to calculate another Challan [Y][N] :";
cin>>op;
if(op=='y' || op == 'Y'){
continue;
}else

coutendlendl;
cout"-----------------------------"endl;
cout"Thank you for paying challan "endl;
cout" PAKISTAN TRAFFIC POLICE "endl;
cout"-----------------------------"endl;
break;
}
}
system("pause");
}
#include<iostream.h> main(){  int choice, days, fine; char op; cout"**********************************************"endl; cout"   Challan Calculator for Traffic Violation   "endl; cout"**********************************************"endl; while(1){ coutendl; cout"    Enter '1' for breaking signals"endl; cout"    Enter '2' for over Speeding"endl; cout"    Enter '3' for not wearing seat belt"endl; coutendl; cout"Enter a type of traffic violation(1 , 2 , 3) :"; cin>>choice;  if(choice == 1 || choice == 2 || choice == 3){                      switch(choice){                                                    case 1:                               cout"Enter the number of days passed till challan date :";                               cin>>days;                               if(days <= 10){                               coutendl;                               cout"The Total Challan is : "500" Rs"endl;                               }else                               if(days > 10      && days<=30){                               coutendl;                               cout"The Total Challan is : "500*2" Rs"endl;                               }else{                               coutendl;                               cout"The Total Challan is : "500*2+((500*2)/2.0)" Rs"endl;                                             }                               break;                                                              case 2:                               cout"Enter the number of days passed till challan date :";                               cin>>days;                               if(days <= 10){                               coutendl;                               cout"The Total Challan is : "300" Rs"endl;                               }else                               if(days > 10      && days<=30){                               coutendl;                               cout"The Total Challan is : "300*2" Rs"endl;                               }else{                               coutendl;                               cout"The Total Challan is : "300*2+((300*2)/2.0)" Rs"endl;                                             }                          break;                          case 3:                               cout"Enter the number of days passed till challan date :";                               cin>>days;                               if(days <= 10){                               coutendl;                                       cout"The Total Challan is : "200" Rs"endl;                               }else                               if(days > 10      && days<=30){                               coutendl;                               cout"The Total Challan is : "200*2" Rs"endl;                               }else{                               coutendl;                               cout"The Total Challan is : "200*2+((200*2)/2.0)" Rs"endl;                                             }                          }                                 }else{                 cout"Enter a valid type of traffic violation"endl;                 }                 coutendl;                 cout"Do you want to calculate another Challan [Y][N] :";                 cin>>op;                 if(op=='y'    ||   op == 'Y'){                               continue;                               }else                               {                                        coutendlendl;                                    cout"-----------------------------"endl;                                    cout"Thank you for paying challan "endl;                                    cout"   PAKISTAN TRAFFIC POLICE   "endl;                                    cout"-----------------------------"endl;                                    break;                                    } } system("pause"); } 

#include <iostream.h>
main()
{
int choice, days, fine;
char op;
cout" <*<*<*<*<*< Challan Calculator for Traffic Violation >*>*>*>*>*> "endl;
while(1)
{
coutendl;
cout" Enter '1' for breaking signals"endl;
cout" Enter '2' for over Speeding"endl;
cout" Enter '3' for not wearing seat belt"endl;
coutendl;
cout"Enter a type of traffic violation(1 , 2 , 3) :";
cin>>choice;

if(choice == 1 || choice == 2 || choice == 3)
{
switch(choice)
{
case 1:
cout"Enter the number of days passed till challan date :";
cin>>days;
if(days <= 10)
{
coutendl;
cout"The Total Challan is : "500" Rs"endl;
}
else
if(days > 10 && days<=30){
coutendl;
cout"The Total Challan is : "500*2" Rs"endl;
}else{
coutendl;
cout"The Total Challan is : "500*2+((500*2)/2.0)" Rs"endl;
}
break;
case 2:
cout"Enter the number of days passed till challan date :";
cin>>days;
if(days <= 10){
coutendl;
cout"The Total Challan is : "300" Rs"endl;
}
else
if(days > 10 && days<=30)
{
coutendl;
cout"The Total Challan is : "300*2" Rs"endl;
}
else
{
coutendl;
cout"The Total Challan is : "300*2+((300*2)/2.0)" Rs"endl;
}
break;
case 3:
cout"Enter the number of days passed till challan date :";
cin>>days;
if(days <= 10)
{
coutendl;
cout"The Total Challan is : "200" Rs"endl;
}
else
if(days > 10 && days<=30)
{
coutendl;
cout"The Total Challan is : "200*2" Rs"endl;
}
else
{
coutendl;
cout"The Total Challan is : "200*2+((200*2)/2.0)" Rs"endl;
}
}
}
else
{
cout"Enter a valid type of traffic violation"endl;
}
coutendl;
cout"Do you want to calculate another Challan [Y][N] :";
cin>>op;
if(op=='y' || op == 'Y')
{
continue;
}
else
{
coutendlendl;
cout"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"endl;
cout" Thanks for your co-operation "endl;
cout" TRAFFIC LAW ENFONCEMENT OF PAKISTAN "endl;
cout"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"endl;
break;
}
}
system("pause");
}

CS201 1st Assignment Solution spring 2012


Solution : 

#include<iostream.h>
main(){
// declaring variables to save data in the programe 
int volType, amountOfFine, noOfDays;
char choice;

// Taking input from the user 
a: cout"*****CHALLAN CALCULCULATION FOR TRAFFIC VOILATION ******** ";
cout"{Enter '1' for breaking traffic signal"endl;
cout"Enter '2' for over speeding"endl;
cout"Enter '3' for not wearing seat belt }"endl;
cout"Please Enter the Voilation Type (1,2 or 3) : ";
cin>>volType;

// cheking the validity of the input givn by the user 
if(volType>3||volType<1)
{
coutvolType" Is an Invalid Choice Please Enter a valid type of traffic violation : ";
goto a; }
if(volType==1)
{

amountOfFine=500;
}else if(volType==2)
{
amountOfFine=300;
}else if(volType==3)
{

amountOfFine=200;
}

// taking input from user 
cout"Please Enter the No. Of Days till Challan : ";
cin>>noOfDays;
// After Calculating the Amount of fine giving feed back to the User 
if(noOfDays<=10)
{

cout"The Total Amount of Challan =" amountOfFineendl;
}else if(noOfDays>10&&noOfDays<=30)
{

cout"The Total Amount of Challan =" amountOfFine+amountOfFineendl;
} else if(noOfDays>30)
{

cout"The Total Amount of Challan =" amountOfFine+amountOfFine+amountOfFine/2endl;

cout"\N Do you want to mak another calculation! Press Y for yes and press N for No"endl;
cin>>choice;
// Lopeing back to the Next calculation on users choice
while (choice=='y'||choice=='Y')
{goto a;}
cout "Take Care Allah Hafiz" endl;
system("PAUSE");
}





One another More Solution : 


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

main()

{
char i;
int a, b;

do

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

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;
coutendl;

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;
coutendl;

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: 
coutendl;
coutendl;
cout"Please Enter a Valid Type of Traffic Violation:";
coutendl;
coutendl;
getch();
coutendl;
coutendl;
system("cls");
main();
break;

}

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

}

RSS

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service