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}

Penulis : Unknown ~ Sebuah blog yang menyediakan berbagai macam informasi

Artikel Calculate The Momentum Of An Object In Java ini dipublish oleh Unknown pada hari . Semoga artikel ini dapat bermanfaat.Terimakasih atas kunjungan Anda silahkan tinggalkan komentar.sudah ada 0 komentar: di postingan Calculate The Momentum Of An Object In Java
 

0 comments:

Post a Comment

Leave Me a Comment Below. Thanks :)