-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMinNumCarAccidents.cpp
More file actions
59 lines (54 loc) · 1.77 KB
/
MinNumCarAccidents.cpp
File metadata and controls
59 lines (54 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//CSC114-651
//Student: Christopher Yonek (700642859)
//Assignment: Create a program that finds the min number of accidents given data for each region.
//Date: September 2018
#include "pch.h"
#include <iostream>
#include <conio.h>
int getNumAccidents(int accidents) {
if (accidents <= 0)
{
std::cout << "You must enter a number greater than 0.\n";
}
else {
return accidents;
}
}
int main(){
using namespace std;
int north, south, east, west, central;
std::cout << "Enter autombile accidents for the past year in northern region\n";
std::cin >> north;
std::cout << "Enter autombile accidents for the past year in southern region\n";
std::cin >> south;
std::cout << "Enter autombile accidents for the past year in eastern region\n";
std::cin >> east;
std::cout << "Enter autombile accidents for the past year in western region\n";
std::cin >> west;
std::cout << "Enter autombile accidents for the past year in centeral region\n";
std:: cin >> central;
int min = getNumAccidents(north);
if (getNumAccidents(south) < min)
min = getNumAccidents(south);
if (getNumAccidents(east) < min)
min = getNumAccidents(east);
if (getNumAccidents(west) < min)
min = getNumAccidents(west);
if (getNumAccidents(central) < min)
min = getNumAccidents(central);
std::cout << "The minimum car accidents is: " << min;
_getch();
return 0;
}
void findlowest() {
int min = getNumAccidents(north);
if (getNumAccidents(south) < min)
min = getNumAccidents(south);
if (getNumAccidents(east) < min)
min = getNumAccidents(east);
if (getNumAccidents(west) < min)
min = getNumAccidents(west);
if (getNumAccidents(central) < min)
min = getNumAccidents(central);
std::cout << "The minimum car accidents is:" << min;
}