C++ Programming Windows Application Console
C++ Program:
/* C++ Program that calculates the distance fallen by watermelon */
#include <iostream>
using namespace std;
//Main function
int main()
{
int time, i;
double distance, height;
//Reading time
cout << "\n Please input the time of fall
in seconds: ";
cin >> time;
//Reading height of bridge
cout << "\n Please input the height of
bridge in meters: ";
cin >> height;
//Printing header
cout << "\n \t Time Falling (seconds)
Distance Fallen (meters) \n ";
cout << "
*********************************************************** \n
";
//Iterating over time from 0 to t
for(i=0; i<=time; i++)
{
//Calculating
distance
distance = 0.5 * 9.8 *
(i*i);
//Printing time and
distance
cout << "\n \t "
<< i << " \t\t\t " << distance;
//Checking for
distance
if(distance >
height)
{
//If distance crossed height
cout << "\n Warning - Bad Data: The distance fallen exceeds
the height of the bridge. \n\n";
return 0;
}
}
cout << "\n\n";
return 0;
}
Sample Run:
C++ Programming Windows Application Console Student Generated Problem Option 2.5 Option 2.5: Suppose Dave drops a...
Watermelon Problem: The answer should not include any whitespace. #include<iostream> using namespace std; int main() { double distance, gravity =9.8, height; int time, t=0; cout<<"Please input the time of fall in seconds:"<<endl; [ A ] // Get the user input of the time of fall in seconds (Use cin>> method) cout<<endl; cout<<"Please input the height of the bridge in meters:"<<endl; [ B ] // Get the user input of the height of the bridge in meters (Use cin>>...
Please can someone help me to finish this program? It is a C programming not a C++, when programming the program in linux I keep getting expected expression before || token, also please check if everything else is fine, maybe there is something else worng in my program and may ask me later to fix it, I am concern about the sin and cosine. The program is supposed to do all this: 1.Display a welcome message. 2.Prompt for the height...
Homework-2 – Working with a class. Problem: Attached with this homework is code for a class called DroppedObject. This class is used to to store the state of a falling object. The problem this class/object can be used to solve is detailed below. Your task for this homework is to read and understand the attached class. Note this class is formatted like all classes should be with private variables, constructors, a toString method, getter and setter methods, and other relevant...
Write a MATLAB Graphical User Interface (GUI) to simulate and plot the projectile motion – the motion of an object projected into the air at an angle. The object flies in the air until the projectile returns to the horizontal axis (x-axis), where y=0. This MATLAB program should allow the user to try to hit a 2-m diameter target on the x-axis (y=0) by varying conditions, including the lunch direction, the speed of the lunch, the projectile’s size, and the...
5.15 PROGRAM: Functions - Upset Fowls (C++) (1) Correct the first FIXME by moving the intro text to the function stub named PrintIntro and then calling the PrintIntro function in main. Development suggestion: Verify the program has the same behavior before continuing. (2) Correct the second FIXME by completing the function stub GetUsrInpt and then calling this function in main. Notice that the function GetUsrInpt will need to return two values: fowlAngle and fowlVel. (3) Correct the third FIXME by...