When you define an
int
, it already starts with the value of 0. Though, giving it the value of 0 is fine too! Just wanted to let you know, in case you didn't:)
Now, my skills are a little rusty, but I'll try to give you the best advice that I can. I also don't know how far you are in your homework, so if any of this hasn't been covered by your course yet, feel free to pick and choose what to use, depending on what you already know.
Your program will never get to your second function, because it is not called in
main
(of course, not called outside of what you have commented). Your second function must also be defined
before main, in order for it to it to work. You can either move your second function above main, or define it like this:
double ticketcalculation(double overlimit);
as long as it's
before main!
If you'd like to brush up on your knowledge of functions:
http://www.cplusplus.com/doc/tutorial/functions/
Now, it's time to call your function,
double ticketcalculation(double overlimit)
in
main
Get it out of the comments! Try it out.
I almost forgot! Your if statements need a little help. You're on the right track, just not quite there.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
if (overlimit >= 1 && overlimit <= 9)
{
fine = 0;
}
else if (fine > 10)
{
fine = 100.00;
}
else if (fine > 20)
{
fine = 150.00;
}
else if (fine >= 25)
{
fine = 250.00;
}
|
Read more about if statements here!
http://www.cplusplus.com/doc/tutorial/control/
I tested it out myself, and it seems to work just fine:)
By the way, it's really recommended that you
don't use system functions. For pausing, I like to use
this_thread::sleep_for (std::chrono::seconds(int));
You'll need to
#include <thread>
and
#include <chrono>
Read about it here!
http://www.cplusplus.com/reference/thread/this_thread/sleep_for/
Edit: I spent so long writing this, there were already two other answers by the time I finished lol.