Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem: You are going to modify in this problem the program written in problem

ID: 3665709 • Letter: P

Question

Problem:

You are going to modify in this problem the program written in problem 1 to make it generate tables showing the braking distance for different distances and road conditions. Generating tables mean repeating something for each line and this will be our first program with a loop. We have used in problem 1 a coefficient of friction between the road and the tires and we have used value 0.7, which is for a dry road. For a wet road, a more correct coefficient would be 0.4, and for wet snow 0.3. Your program will ask for a “start speed”, and for a “top speed”, and will generate a table in which you will display on each row (b.d. stands for “braking distance”) Speeds will go from the “start speed” to the “top speed” with a 5mph increment between two successive rows. If the start speed is NOT a multiple of 5, you will start from the multiple of 5 immediately inferior to the start speed entered. If the top speed is NOT a multiple of 5, the last row will contain the smallest multiple of 5 greater than the top speed that was provided.

I got the first problem done but I'm not sure on this one because i keep getting errors.

problem 1:

#include<stdio.h>

float braking_distance;

int speed;

int main (void)

{

char input[80];

float feet_per_second;

printf("Enter the value of speed in mph");

scanf('%d", &speed);

feet_per_second=speed*(5280.0/3600.0);

braking_distance=feet_per_second+(feet_per_second*feet_per_second)/(2.0*0.70*32.17);

printf("Distance to stop, %f feet ", braking_distance);

return 0;

}

Explanation / Answer

to show braking distance b.d = feet_per_second+(feet_per_second*feet_per_second)/(2.0*0.70*32.17) for dry road

b.d for wet road will be feet_per_second+(feet_per_second*feet_per_second)/(2.0*0.40*32.17)

b.d for snow road will be feet_per_second+(feet_per_second*feet_per_second)/(2.0*0.30*32.17)

and feet_per_second=speed*(5280.0/3600.0)

i/p = start speed and top speed

o/p = table with braking distance for different types of road.

the output must be

low speed (speed = or less than multiple of 5), High speed (speed = or more than multiple fo 5), b.d dryfloor , b.d wetfloor, b.d. snow floor

program

#include<stdio.h>

#include<math.h>

float bd_dry;

float bd_wet;

float bd_snow;

int speed;

int start_speed;

int top_speed,

int main (void)

{

char input[80];

float feet_per_second;

printf("Enter the value of low speed in mph");

scanf('%d", &start_speed);

printf("Enter the value of low speed in mph");

scanf('%d", &top_speed);

/* round the start_speed and top_speed to the multiple of 5

int rem;

rem = start_speed % 5;

start_speed = start_speed - 5; //low speed less than given speed and a multiple of 5

rem = top_speed % 5;

int addi;

addi= 5 - rem;

top_speed = top_speed + addi; //top speed is greater than the given speed and multiple of 5

// now the b,d to be calculated from low speed to top speed

int i;

printf("Distance to stop ",);

printf (" dry floor wet floor snow floor");

for ( i = low_speed, i <=top_speed, i++)

{

if (i%5 =0) // calculates and displays the speed for multiple of 5 only

{

feet_per_second=i*(5280.0/3600.0)

bd_dry=feet_per_second+(feet_per_second*feet_per_second)/(2.0*0.70*32.17)

bd_wet=feet_per_second+(feet_per_second*feet_per_second)/(2.0*0.40*32.17)

bd_snow= feet_per_second+(feet_per_second*feet_per_second)/(2.0*0.30*32.17)

printf (%f feet, bd_dry)

printf (%f feet, bd_wet)

printf (%f feet, bd_snow)

}

}

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote