From 97a693d996c79fb2a008b19750d8bb45512e01a2 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Mon, 6 Feb 2017 11:26:44 -0500 Subject: Inital commit --- force2.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 force2.c (limited to 'force2.c') diff --git a/force2.c b/force2.c new file mode 100644 index 0000000..8806617 --- /dev/null +++ b/force2.c @@ -0,0 +1,25 @@ +/*File : force2.c Calculate the peicewise time force. The formulas depend on wether time t is 0<=t<=3 or t>0*/ +#include +#define M 3 + +int main() +{ + + double p, t; + printf("Please input time in seconds: "); + scanf("%lf",&t); + if(0<=t && t<=M){ + p = 20; + printf("Force p = %f (N)\n",p); + } + else if(t>3) + { + p = 4*(t+2); + printf("Force p = %f (N)\n",p); + } + else + { + printf("Invalid input, time is never negitive\n"); + } + return 0; +} -- cgit v1.2.3-70-g09d2