-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile_error.cpp
34 lines (27 loc) · 919 Bytes
/
compile_error.cpp
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
// Code for Project 1
// Report poll results
#include <iostream>
using namespace std;
int main()
{
int numberSurveyed;
int forGavin;
int forBrian;
cout << "How many registered voters were surveyed? ";
cin << numberSurveyed;
cout << "How many of them say they will vote for Gavin? ";
cin << forGavin;
cout << "How many of them say they will vote for Brian? ";
cin << forBrian;
pctGavin = 100.0 * forGavin / numberSurveyed;
pctBrian = 100.0 * forBrian / numberSurveyed;
//cout.setf(ios::fixed);
//cout.precision(1);
cout << endl;
cout << pctGavin << "% say they will vote for Gavin." << endl;
cout << pctBrian << "% say they will vote for Brian." << endl;
if (forGavin > forBrian)
cout << "Gavin is predicted to win the election." << endl;
else
cout << "Brian is predicted to win the election." << endl;
}