java program to find work done by body and to calculate kinetic and potential energy
import java.util.Scanner;
class work
{
public static void main(String [] args)
{
Scanner sc=new Scanner(System.in);
System.out.println("If you want to find out work in terms of displacement on ground choose1 If you want to find out work in terms of gravitychoose 2 If you want to find out kinetic energy choose3 If you want to find potential energy choose 4.");
int ch=sc.nextInt();
if (ch==1)
{
System.out.println("Enter the force applied in newton");
double f=sc.nextDouble();
System.out.println("Enter the displacement in meter");
double d=sc.nextDouble();
System.out.println("Enter the time taken in second");
Double t=sc.nextDouble();
double w=(f*d);
System.out.println("The work done by the force="+w+"J");
double p=(w/t);
System.out.println("The power spent="+p+"w");
}
else if(ch==2)
{
System.out.println("Enter the mass in kg");
double m=sc.nextDouble();
System.out.println("Enter the accleration due to gravity in m/s*s");
double a =sc.nextDouble();
System.out.println("Enter the height in meter");
double h=sc.nextDouble();
System.out.println("Enter the time in second");
double s=sc.nextDouble();
double x=(m*a*h);
System.out.println("Work done ="+x+"J");
double y=(x/s);
System.out.println("Power ="+y+"w");
}
else if(ch==3)
{
System.out.println("Enter the mass in Kg");
double kg=sc.nextDouble();
System.out.println("Enter the velocity in m/s");
double v=sc.nextDouble();
double b=(0.5*kg*v*v);
System.out.println("The kinetic energy="+b+"J");
}
else if(ch==4)
{
System.out.println("Enter the mass in Kg");
double c=sc.nextDouble();
System.out.println(" Enter accleration in m/s*s ");
double d=sc.nextDouble();
System.out.println("Enter the height in meter");
double e=sc.nextDouble();
double f=(c*d*e);
System.out.println("The potential energy ="+f+"J");
}
else
System.out.println("Wrong choice");
}
}
class work
{
public static void main(String [] args)
{
Scanner sc=new Scanner(System.in);
System.out.println("If you want to find out work in terms of displacement on ground choose1 If you want to find out work in terms of gravitychoose 2 If you want to find out kinetic energy choose3 If you want to find potential energy choose 4.");
int ch=sc.nextInt();
if (ch==1)
{
System.out.println("Enter the force applied in newton");
double f=sc.nextDouble();
System.out.println("Enter the displacement in meter");
double d=sc.nextDouble();
System.out.println("Enter the time taken in second");
Double t=sc.nextDouble();
double w=(f*d);
System.out.println("The work done by the force="+w+"J");
double p=(w/t);
System.out.println("The power spent="+p+"w");
}
else if(ch==2)
{
System.out.println("Enter the mass in kg");
double m=sc.nextDouble();
System.out.println("Enter the accleration due to gravity in m/s*s");
double a =sc.nextDouble();
System.out.println("Enter the height in meter");
double h=sc.nextDouble();
System.out.println("Enter the time in second");
double s=sc.nextDouble();
double x=(m*a*h);
System.out.println("Work done ="+x+"J");
double y=(x/s);
System.out.println("Power ="+y+"w");
}
else if(ch==3)
{
System.out.println("Enter the mass in Kg");
double kg=sc.nextDouble();
System.out.println("Enter the velocity in m/s");
double v=sc.nextDouble();
double b=(0.5*kg*v*v);
System.out.println("The kinetic energy="+b+"J");
}
else if(ch==4)
{
System.out.println("Enter the mass in Kg");
double c=sc.nextDouble();
System.out.println(" Enter accleration in m/s*s ");
double d=sc.nextDouble();
System.out.println("Enter the height in meter");
double e=sc.nextDouble();
double f=(c*d*e);
System.out.println("The potential energy ="+f+"J");
}
else
System.out.println("Wrong choice");
}
}
6 comments
to see this web site, it consists of valuable Information.
It's a very easy on the eyes which makes it much more pleasant for me to come
here and visit more often. Did you hire out a designer to create
your theme? Exceptional work!
time as you amend your site, how could i subscribe for a blog web
site? The account helped me a applicable deal. I have been a little bit
familiar of this your broadcast offered bright transparent concept
It appears like some of the written text within your content
are running off the screen. Can someone else please provide
feedback and let me know if this is happening to them as well?
This might be a issue with my browser because I've
had this happen previously. Kudos
Thx!