Probably a dumb Question!

Hey, I have a question, and I know that it is going to be a wow-i-am-a-moron-how-did-i-forget-that type of question.

I am making a little program to find the total for a fine for a speeding driver. The user enters their actual speed, the speed limit, and if they were or were not using a seat belt. For every 1-mph over the limit, the fine is increased by $2.00. if there is no seatbelt, then that is +$42.00. the base fine is $80.00. I think that is all the information that you would need to know to help me. Here is the code, and below it is the error code!
Thanks a ton!

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
//Name: fine.cpp
//Author: Jake
//Date: November 26th 2008
//Description:
//

#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main()
{
string response ="n";
double limit;
double speed;
char a;
double extra;

do
{
cout << "Welcome to Fine Calculator!" << endl;
cout << "Please enter the Speed Limit:" << endl;
cin >> limit;
cout << "Please enter the Driver's Speed:" << endl;
cin >> speed;
cout << "Was Driver wearing a Seat Belt?: [y/n]" << endl;
cin >> a;
cout << "Thank you!" << endl;

if (a=="y")
{extra=42;}

if (a=="n")
{extra=0;}

cout << "Your total fine is: $" << 80+((speed-limit)*2)+a << endl;
cout << " " << endl;
cout << "Do you want to do this again? [enter y for yes]" << endl;
cin >> response;
}
while (response == "Y" || response == "Yes" || response == "y" || response == "yes");
}


1
2
3
fine.cpp: In function `int main()':
fine.cpp:31: ANSI C++ forbids comparison between pointer and integer
fine.cpp:34: ANSI C++ forbids comparison between pointer and integer 


Thank you i hope someone can help me!
Single quotes for characters ('y').
Last edited on
ahh, right!
I knew it would be something stupid of me.
Thanks!
Oh, right. Don't use single quotes if the character is really supposed to be a C string that will be compared to an std::string.
Topic archived. No new replies allowed.