Yeah, what I was talking about your variable declarations at the beginning of int main()
1 2 3 4
|
int main ()
{
double tickets, credits, cost,
name, response;
|
What you are doing here is declaring all of your variables of type double.
If you don't know what type is:
http://www.cplusplus.com/doc/tutorial/variables/
What you need to do is one of the most important parts of your program - saying what values these variables can and can't take.
For example let's look at my quip about how my name is not of type double.
I assume you read that tutorial, but in case it wasn't clear,
double
is C++ for a double floating point variable. Which means it can be a decimal number for example 3.456.
So you declared the variable "name" to
need to be a double floating point variable, meaning it
can only be a decimal number like 3.434. Unfortunately, you then wanted the client to input their name into a variable that can only hold decimal digits.
Your user inputs his name in letters. This throws what is called an exception and terminates your program.
In order to prevent such a thing from happening, you need to declare something to hold names which are of type char *
Therefore you could either take the C route (which I don't advise yet) or the C++ string route.
Since you now have included <string> you can create string objects.
They are super easy to do.
string mystring = "This is a string"; // mystring is the name of your string.
So in the case of your program you have the following variables:
tickets,
credits,
cost,
name,
response;
Each of these needs a type based on what data you want to store in it. But I'll leave you to take it from here.
I highly recommend using the tutorial on this website to guide you as you learn C++.
Good luck, Have Fun with C++,
Sean