/*********************************************************** dist-rate-time.ch Distance, Rate and Time This program calculates the distance, rate or time of a situation when given 2 of the other parameters. ************************************************************ Copyright 2014 SoftIntegration Inc. http://www.softintegration.com Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 ***********************************************************/ //Initialize variables char which_one; double rate, time, distance; //Get which one is the variable to be solved printf("which value (r)ate, (d)istance, (t)ime do you need? "); scanf("%c",&which_one); //Solve and display for rate if(which_one == 'r') { printf("enter the distance "); scanf("%lf",&distance); printf("enter the time "); scanf("%lf",&time); rate = distance/time; printf("rate is %lf\n",rate); } //Solve and display for distance else if(which_one == 'd') { printf("enter the rate "); scanf("%lf",&rate); printf("enter the time "); scanf("%lf",&time); distance = rate*time; printf("distance is %lf\n",distance); } //Solve and display for time else if(which_one == 't') { printf("enter the rate "); scanf("%lf",&rate); printf("enter the distance "); scanf("%lf",&distance); time = distance/rate; printf("time is %lf\n",time); }