Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // SafeDrivingArea.cpp : Defines the entry point for the console application.
- //
- #include"stdafx.h"
- #include<iostream>
- #include<iomanip>
- #include<string>
- using namespace std;
- int getNumAccidents(string regionName)
- {
- int numAccidents;
- do
- {
- cout << "Enter the number of accidents for "<<regionName;
- cin>>numAccidents;
- }while (numAccidents < 0);
- return numAccidents;
- }
- void findLowest(int north, int south, int east, int west, int central,int &numAccidents)
- {
- string locationName;
- for (int i = 1; i < numAccidents; i++)
- {
- if (numAccidents > north){locationName = "north";}
- if (numAccidents > south){locationName = "south";}
- if (numAccidents > east){locationName = "east";}
- if (numAccidents > west){locationName = "west";}
- if (numAccidents > central){locationName = "central";}
- }
- cout<<"\n";cout<<"\n";
- cout<<"The Safest Area: "<<locationName<<endl;
- }
- int main()
- {
- system("Color 17");
- string locationName;
- int north,south,east,west,central,numAccidents;
- cout<<"There are 5 locations inside the city.\n";
- locationName="north:";
- north = getNumAccidents(locationName);
- locationName="south:";
- south = getNumAccidents(locationName);
- locationName="east:";
- east = getNumAccidents(locationName);
- locationName="west:";
- west = getNumAccidents(locationName);
- locationName="central:";
- central = getNumAccidents(locationName);
- findLowest(north,south,east,west,central,numAccidents);
- cout<<"\n";cout<<"\n";
- cout<<"\n";cout<<"\n";
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement