OO TMobile F 18 I 1158 PM web mstedu Write a program that al

OO T-Mobile F 18% I 11:58 PM web mst.edu Write a program that allows the user to enter a time in seconds and then outputs how far an object would drop if it is in freefall for that length of time Assume that the object starts at rest, there is no friction or resistance from air and there is a constant acceleration of 32 feet per second squared due to gravity. Use the equation acceleration (time) 2 distance Note that the used to indicate exponentiation is not an actual operator in C++ I just used it here in English to desribe what you are doing. You should use 2 loops in your program. The outer loop will be used to control whether or not the computation is run addtional times, to allow multiple inputs to be given. Data checking The inner loop will be used to verify the data is valid for the computation to take place Assume a time of 0 or a positive time will be acceptable. Any negative time should generate a warning to the user that the time is not valid, and no computation for that inappropriate value should take place. We will discuss data checking in class, and you can also consult the web page I have that addresses this See http://web.mst.edu/-davem/CSc74/programs/dowhile.ba sics. fs2007 When your program asks for input, for values to use 10

Solution

#include<iostream>
#include <cmath>

using namespace std;


int main() {
   //declare variables here
   double acceleration= 32.0;

   char cAgain;
   //cAgain= \"Y\";
   double time;

   do
   {

      do
      {

       cout << \"Please enter time value to simulate...greater than 0 \";
       cin>>time;


         if(time<=0)
         {
            cout << \"you are a blithering idiot -- your input is BAD\" << endl;
            cout << \"Please try again\" << endl;
         }

      } while(time<=0);
    

      // processing valid time value
      double distance= (acceleration * pow(time,2.0) )/2;
    
      cout<<\"the distance covered is: \"<<distance<<endl;
      cout << \"You want to run another set of data? Y/y/N/n \" << endl;
      cin >> cAgain;

   }while(cAgain == \'Y\' || cAgain == \'y\');

   return 0;
}

 OO T-Mobile F 18% I 11:58 PM web mst.edu Write a program that allows the user to enter a time in seconds and then outputs how far an object would drop if it is

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site