CÁLCULO DE VELOCIDAD FINAL
María Guadalupe García Muñoz|Programar o morir UNIVERSIDAD TECNOLOGICA DEL VALLE DE TOLUCA
Contenido OBJETIVO ............................................................................................................................................. 2 EJEMPLO .............................................................................................................................................. 2
MARÍA GUADALUPE GARCÍA MUÑOZ|PROGRAMAR O MORIR
1
OBJETIVO Mediante este código se puede calcular simplemente la velocidad final, a través de u código sencillo de java.
EJEMPLO //Este programa es para calcular la velocidad final //Creamos la clase velocidad con dos variables inicializadas en 0 public class Velocidad { double vo=0,aceleracion=8; double VelocidadMedia() { //velocidad_final=velocidad_inicial+(aceleracion*tiempo) double vf=0,tiempo=5; vf=vo+(aceleracion*tiempo); double speedMedia=(vo+vf)/2; return speedMedia; } //Velocidad de algun instante de tiempo en este caso tiempo se inicializa con un valor de 5 //Es decir que nuesta velocidad se calculara en un tiempo de 5 double VelocidadInstant() { double tiempo=5; double speedInst=(vo+aceleracion*tiempo); return speedInst; } //PRICIPAL Aqui se manda a llamar los metodos public static void main(String[] args) MARÍA GUADALUPE GARCÍA MUÑOZ|PROGRAMAR O MORIR
2
{
DSCSpeedy coche = new DSCSpeedy();
double vMedia=coche.VelocidadMedia(); System.out.println(vMedia+" m/s"); double vInstantanea=coche.VelocidadInstant(); System.out.println(vInstantanea+" m/s"); } }
MARÍA GUADALUPE GARCÍA MUÑOZ|PROGRAMAR O MORIR
3