Casualidad... una amiga me paso ese problema jajaja
no te enojes amigo.
No todos te van a responder siempre...
#include <iostream>
#include <conio.h>
#include <math.h>
using namespace std;
class CannonBall
{
private:
float xVel, yVel, gv , x, y,tetha;
public:
//xVel
float getxVel() const; //accessor
void setxVel(float velocity, float tetha); //mutator
//yVel
float getyVel() const; //accessor
void setyVel(float velocity, float tetha); //mutator
//GV
float getgv() const; //accessor
void setgv(float time); //mutator
//X
float getX() const; //accessor
void setX(float time); //mutator
//Y
float getY() const; //accessor
void setY(float time); //mutator
//Print
void CannonBall::Imprimir();
};
//XVEL
float CannonBall::getxVel() const {return xVel;}; //accessor
void CannonBall::setxVel(float velocity, float tetha) { xVel=velocity*cos(tetha); }; //mutator
//YVEL
float CannonBall::getyVel() const {return yVel;}; //accessor
void CannonBall::setyVel(float velocity, float tetha) { yVel=velocity*sin(tetha); }; //mutator
//GV
float CannonBall::getgv() const {return gv;}; //accessor
void CannonBall::setgv(float time){ gv=yVel-(time*9.8); }; //mutator
//X
float CannonBall::getX() const {return x;}; //accessor
void CannonBall::setX(float time){ x=x+(time*xVel); }; //mutator
//Y
float CannonBall::getY() const {return y;}; //accessor
void CannonBall::setY(float time){ y=y+time*(yVel-gv)/2; yVel=gv;}; //mutator
//PRINT
void CannonBall::Imprimir()
{
cout<<" "<<x;
cout<<" "<<y<<endl;
}
int main ()
{
CannonBall bullet;
float height, interval, angle, velocity; //estos valores los pongo aqui porque no los voy aux modificar en los metodos de la clase
float tetha, time=0, aux=0, max=0;
cout<<"Angulo:"<<endl;
cin>>angle;
cout<<"Velocidad:"<<endl;
cin>>velocity;
cout<<"Altura:"<<endl;
cin>>height;
cout<<"Intervalo:"<<endl;
cin>>interval;
tetha=(angle*3.14)/180;
bullet.setxVel(velocity, tetha);
bullet.setyVel(velocity, tetha);
cout<<"t, x, y"<<endl;
do
{
bullet.setX(time);
bullet.setgv(time);
bullet.setY(time);
if (bullet.getY()>=0)
{
bullet.Imprimir();
cout<<time<<" ";
}
if (max<bullet.getY())
{
max=bullet.getY();
}
time+=interval;
aux=bullet.getY();
}while (aux<=0);
cout<<"La altura maxima es: "<<max<<endl;
cout<<"Tiempo antes de tocar el suelo: "<<time<<endl;;
getch();
return 0;
}
Derecho de Autor: Cruz!
^^