Hi. I'm really new to programming and my teacher said we need to write a c program that finds a fine for someone speeding.
I am using xcode instead of the borland compiler on windows, so the teacher said he won't help me unless i use windows, but i hate it yuck!
It compiles ok in xcode, but doesnt really work properly
All i get is a fine for $80 even when i know it should be more than that.
My code is at the bottom.
Please help me! Thank you so much in advance all you smart boys out there!!! I appreciate it!
- Jen
}
I am using xcode instead of the borland compiler on windows, so the teacher said he won't help me unless i use windows, but i hate it yuck!
It compiles ok in xcode, but doesnt really work properly
All i get is a fine for $80 even when i know it should be more than that.
My code is at the bottom.
Please help me! Thank you so much in advance all you smart boys out there!!! I appreciate it!
- Jen
Code:
#include <stdio.h>
int main()
{
const int SPEED_LIMIT = 60;
const int SPEED_LIMIT2 = 80;
const int SPEED_LIMIT3 = 150;
int carspeed;
int fine;
printf("Please input speed: ");
scanf("%d%*c", &carspeed);
if (carspeed >= SPEED_LIMIT)
{
printf("Speeding");
}
else
if (carspeed <= SPEED_LIMIT2)
{
fine = 80;
printf("Speeding, your fine is: %d%*c", fine);
}
else
if (carspeed <= SPEED_LIMIT3)
{
fine = 150;
printf("Speeding, your fine is: %d%*c", fine);
}
else
fine = 500;
return (0);