Thread: Program help

  1. #16
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    First, knock 45 points off the speed: speed -= 45
    Then, see if that's > 0 (ie: speed is greater than 45).
    If it is, start adding to the ticket.
    Add 10 bucks for the first ten over.
    Add 15 bucks for each of the second ten over.
    Add 20 bucks for everything else.

    At least that's the theory. I didn't bother testing it.


    Quzah.
    Hope is the first step on the road to disappointment.

  2. #17
    Registered User
    Join Date
    Feb 2010
    Posts
    96
    thanks for explainig

  3. #18
    Registered User GL.Sam's Avatar
    Join Date
    Aug 2009
    Posts
    88
    http://cboard.cprogramming.com/membe...ng#vmessage334
    Umm, that's nice. "I'm a beginner so I should use it as an excuse." You will not dictate what I need and what I don't.
    The only good is knowledge and the only evil is ignorance.
    ~Socrates

  4. #19
    Registered User
    Join Date
    May 2010
    Posts
    6
    Okay, pretty sure I got it. Wasn't hard at all once I figured out the formulas to use.

    Code:
    /*
    @author:
    @date/version:20100512.01
    @title:Fine Calculator
    */
    
    #include <stdio.h>
    
    int main (void){
    
    //declarations
    int speed;
    int fine;
    
    //give the user information on what to do
    printf("Please input the speed of the vehicle:\n");
    //get input
    
    scanf("%d",&speed);
    if(speed<=45 ){
    printf("No fine is given.\n");
    }
    else if(speed>45 && speed<56){
    fine=(speed-45)*10;
    printf("The fine is $%d.\n", fine);
    }
    else if(speed>55 && speed>66){
    fine=(speed-55)*15+100;
    printf("The fine is $%d.\n", fine);
    }
    else if(speed>65){
    fine=(speed-65)*20+250;
    printf("The fine is $%d.\n", fine);
    }
    
    return 0;
    }

    Thank you, everyone, for the help!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM