Having trouble writing a formula

This is a discussion on Having trouble writing a formula within the C Programming forums, part of the General Programming Boards category; I have this homework assigned for my programming class and I'm having trouble writing the following formula: Time (in minutes) ...

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    32

    Question Having trouble writing a formula

    I have this homework assigned for my programming class and I'm having trouble writing the following formula:

    Time (in minutes) = (12 | 12 t |)*g/a

    where t is equal to the time of day (in military time)
    a is equal to parking spots availabe
    and g is equal to parking permits given

    Code:
     #include<stdio.h>
       int main () {
           
           int t, a, g;
           double total_time_to_wait;
           
           printf("What hour are you looking for parking?\n");
           scanf("%d", &t);
           
           printf("How many sports are availabe this semester?\n");
           scanf("%d", &a);
           
           printf("How many parking permits were given this semester?\n");
           scanf("%d", &g);
           
           total_time_to_wait= (12-|(12-t)|)*(g/a);
           printf("You will have to wait %.2lf to find parking.", total_time_to_wait);
           
           system("PAUSE");
           return 0;
           
           }

    Not really sure if I'm writing the right way

  2. #2
    Registered User
    Join Date
    Sep 2009
    Posts
    32
    EDIT: the second question should be "How many spots..."

  3. #3
    Registered User
    Join Date
    Sep 2009
    Posts
    32
    never mind, problem solved

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 08-17-2009, 09:25 AM
  2. Trouble Writing To File
    By NuNn in forum C Programming
    Replies: 2
    Last Post: 03-23-2009, 10:44 AM
  3. Trouble writing to file using fwrite()
    By yougene in forum C Programming
    Replies: 4
    Last Post: 12-30-2008, 05:13 PM
  4. Replies: 1
    Last Post: 04-05-2002, 11:19 AM
  5. Writing Bitmap Files
    By HappyDude in forum C++ Programming
    Replies: 1
    Last Post: 10-13-2001, 06:48 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21