Friday 29 June 2012

Calculate The Momentum Of An Object In Java

 An object's momentum is its mass multiplied by its velocity. Write a program that expects an object's mass (in kilograms) and velocity ( in meters per second) as inputs and prints its momentum.

This program used Scanner method for getting user's input. Save this file as Momentum.java.

01import java.util.Scanner;
02 
03public class Momentum {
04  public static void main(String [] args) {
05    Scanner in      = new Scanner(System.in);
06    double mass     = 0.0;
07    double velocity = 0.0;
08 
09    System.out.print("Enter object's mass in kilograms: ");
10    mass = in.nextDouble();
11 
12    System.out.print("Enter object's velocity in meter/second: ");
13    velocity = in.nextDouble();
14 
15    System.out.println("The momentum is: " + (mass * velocity));
16 
17 }
18}

2 comments:

  1. Great article with excellent idea!Thank you for such a valuable article. I really appreciate for this great information.. velocity calculator

    ReplyDelete
  2. Calculate The Momentum Of An Object In Java ~ Internet-Publiclab >>>>> Download Now

    >>>>> Download Full

    Calculate The Momentum Of An Object In Java ~ Internet-Publiclab >>>>> Download LINK

    >>>>> Download Now

    Calculate The Momentum Of An Object In Java ~ Internet-Publiclab >>>>> Download Full

    >>>>> Download LINK QT

    ReplyDelete

Internet-PublicLab. Powered by Blogger.