Code:
#include <stdio.h> #include <stdlib.h> #include <math.h> int main() { float zav_pot1, zav_pot2, v0, a, kt, g, t; int x; printf("with this program we will calculate the stoping distance of a car\nwhile taking and not taking in account the reaction time of the driver.\n"); printf("enter starting speed of the vehicle in km/h:\n"); scanf("%f", &v0); printf("Enter reaction time of the driver in seconds:\n"); scanf("%f", &t); printf("enter road conditions:\n1 dry\n2 wet\n3 icy\n"); scanf("%d", &x); switch(x) { case(1): kt=0,6; break; case(2): kt=0,3; break; case(3): kt=0,1; break; default: printf("Run program again and ener a valid value!\n"); system("pause"); return 0; } zav_pot1=(v0*v0)/(2*a); zav_pot2=(v0*t)+((v0+v0)/(2*a)); printf("Stoping distance without reaction time is %.f m.\n", zav_pot1); printf("Stopping distance with reaction time is %f m.\n", zav_pot2); system("PAUSE"); return 0; }
Comment