This demonstrates a few formulas executed upon the start of the program.
CODE
class callit
{
public static void main (String args[]){
System.out.println("__________________________");
//output from classes by creating and object
//turns it from a class to a new object
System.out.println("To calculate the momentum we use mv");
momenTUM ac = new momenTUM();
ac.display();
System.out.println("__________________________");
System.out.println(" To calculate the speed of light we use e=mcc");
lightSPEED ab= new lightSPEED();
ab.display();
System.out.println("__________________________");
}
}
//* Abstract class personAB - write a description of the class here
//This is the superclass in this file
abstract class theCalculator
{
//The abstract class makes every class in this file have a display method.
abstract void display();
//abstract float calculateMe();
}
//This is a subclass of personAB
//Because it is a subclass it has to have a display() method
class momenTUM extends theCalculator{
//float calculateMe(){
float m=4;
float v=2;
float mv=m*v;
//return(mv);
//}
void display(){
momenTUM mt= new momenTUM();
System.out.println(m+" is the mass");
System.out.println(v+" is the speed");
System.out.println(mv+" is the momentum");
//System.out.println(mt.calculateMe());
}
}
//E=mc≤
class lightSPEED extends theCalculator{
//float calculateMe(){
float m=3;
float c=299792458;
float cc=(c*c)*m;
//return(mv);
//return(cc);
//}
void display(){
lightSPEED ls= new lightSPEED();
System.out.println(cc+" is the energy");
System.out.println(c+" is the speed of light");
System.out.println(m+" is the mass of the object");
//System.out.println(ls.calculateMe());
}
}
Now this does not allow for user input if you need that start a new post. But this shows basic math logic.
CN