Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

These are the steps you should do for the C++ Program: 1.- Modify the code so that the variables and are entered by the user

These are the steps you should do for the C++ Program: 1.- Modify the code so that the variables  and  are entered by the user on the keyboard. Move the code of lines 16 and 17 to a function called fEnterData (....) that returns v0x and v0y. 2.- Move the code of lines 18 to 26 inclusive to a function called fShowInitials (....). 3.- Move the code of lines 28 to 40 inclusive to a function called fComputeTrajectory (....). 4.- Move the code of lines 46 to 110 inclusive to a function called fGenerateGraphic (....).

//Code Blocks: Project Build Options Linker settings Other linker options: add -lgdi32 #define _WIN32_WINNT 0x0500 #include "windows.h" //#include "Wingdi.h" #include  #include  #include  using namespace std; #define PI 3.14 #define NMAX 1000 int main(){ ////////////////////////////////////////////////// double G=9.81,ang=53,v0=10,v0x,v0y; //Inicializar el angulo y la velocidad inicial v0x = v0*cos(ang*PI/180); //Velocidad inicial horizontal v0y = v0*sin(ang*PI/180); //Velocidad inicial vertical printf ("Initial speed v0: %.2f. Angle : %.2f ",v0,ang); printf ("v0x: %.2f ",v0x); printf ("v0y: %.2f ",v0y); double tFinal = 2*v0y/G; //tiempo de la bala en el aire double yMax = v0y*tFinal/2-0.5*G*tFinal/2*tFinal/2; printf ("tFinal: %.2f ",tFinal); double Ts=0.1; int N = (int)(tFinal/Ts); printf ("Number of measures: %d ",(N+1)); double x[NMAX+2],y[NMAX+2],t[NMAX+2]; printf ("t: secs. xpos. ypos. vx. vy "); for (int n = 0; n <= N; n++) { t[n]=n*Ts; x[n]=v0x*t[n]; y[n]=v0y*t[n]-0.5*G*t[n]*t[n]; printf ("t%d: %.2f %.2f %.2f %.2f %.2f ", n,t[n],x[n],y[n],v0x,v0y-G*t[n]); } t[N+1]=tFinal; x[N+1]=v0x*tFinal; y[N+1]=v0y*t[N+1]-0.5*G*t[N+1]*t[N+1]; printf ("t%d: %.2f %.2f %.2f %.2f %.2f ", N+1,t[N+1],x[N+1],y[N+1],v0x,v0y-G*tFinal); ////////////////////////////////////////////////////// ////////////////////////////////////////////////////// cout << "Press twice enter to show the graph "; cin.ignore(); system("CLS"); //clear the screen cin.ignore(); HWND myconsole = GetConsoleWindow(); HDC mydc = GetDC(myconsole);//hWnd //SetWindowPos( myconsole, 0, 0, 500, 800, 600, SWP_NOMOVE | SWP_NOZORDER ); RECT rect; COLORREF RED= RGB(255,0,0),BLUE= RGB(0,0,255), WHITE= RGB(255,255,255); GetWindowRect(myconsole, &rect);//get console coordinates //cout << "Console top coords: " << rect.left << " " <                        

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions