Jupiter please do it correctly and show result The speeding

Jupiter. please do it correctly and show result
The speeding ticket fine policy in Potyomkin village is $60.00 plus $5.00 for each mph over the speed limit Moreover, the fine is doubled for any speed limit violation in a construction zone. Furthermore, a penalty of $250.00 is added for any speed over 90 mph. Write a function, called speeding(), that takes three formal parameters a speed limit (int), clocked speed (int) and whether the speed limit violation took place in a construction rone or not (\' \' y\" or \' \'n\") at input, ard either returns zero indicating the speed was legal or returns the amount of the fine, if the speed is illegal. The caller of the function speeding() in the test() function then prints a message using the format shown in the next problem. You must use if statements in your solution. Your speeding() function must not print anything. Do not import external module in your solution. Write a test function, called test(), to test the speeding() function with the following actual parameters and write a message accordingly: Call test() in your program and show the result. Examples of the correct output format include: Speeding notation fine for speed 35 in 50 mph zone (construction-\'Y\'); $0.00 Speeding violation fine for speed 95 in 80 mph zone (construction \'n\'): $385.00

Solution

// program is in C language.

// program for implementing speeding fine based on given requirements. fine =60 and for every 1 mph = $ 5.00 if construction violated(\'y\') fine doubled and
// speed over 90 gets further 250 extra fine.

// including libraries
#include<stdio.h>

//declaration of test and speeding functions.
void test();
int speeding(int , int ,char );
int main(){
   test();                            // calling test function.
}
// speeding functin definition.
int speeding(int sl, int cs,char c_l){
   int value = 0;
   if(sl<cs){                       // if clock speed crosses speeding limit.
       value=60+(cs-sl)*5;              
       if(c_l==\'Y\' || c_l == \'y\'){ // if construction violation occurs.
           value=value*2;
       }
       if(cs>90){                   // if clock speed over 90
           value=value+250;
       }
   }
   return value;                    // speeding function returns value never prints.
}
// test function definition.
void test(){
   printf(\"speeding violation fine for speed %d in %d mph zone(construction = %c) $%d.00\ \",35,45,\'y\',speeding(45,35,\'y\'));// calling speeding function and printing
   printf(\"speeding violation fine for speed %d in %d mph zone(construction = %c) $%d.00\ \",55,45,\'y\',speeding(45,55,\'y\'));
   printf(\"speeding violation fine for speed %d in %d mph zone(construction = %c) $%d.00\ \",55,45,\'n\',speeding(45,55,\'n\'));
   printf(\"speeding violation fine for speed %d in %d mph zone(construction = %c) $%d.00\ \",95,45,\'y\',speeding(45,95,\'y\'));
   printf(\"speeding violation fine for speed %d in %d mph zone(construction = %c) $%d.00\ \",95,45,\'n\',speeding(45,95,\'n\'));
   printf(\"speeding violation fine for speed %d in %d mph zone(construction = %c) $%d.00\ \",95,80,\'n\',speeding(80,95,\'n\'));
}

// end of prgram

// please comment your response. it helps me to provide any additional information you needed.

Jupiter. please do it correctly and show result The speeding ticket fine policy in Potyomkin village is $60.00 plus $5.00 for each mph over the speed limit More
Jupiter. please do it correctly and show result The speeding ticket fine policy in Potyomkin village is $60.00 plus $5.00 for each mph over the speed limit More

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site