Java Bullet Energy Calculator

Here’s some source code I wrote up for a java Bullet Energy Calculator.

import java.util.Scanner;//this is the scanner class needed to get input from the user

public class main {

public static void main(String[] args) {

String choice = “null”;//initializing the choice

int weight = 0,velocity = 0;//the two variables with initialization

while (!choice.equals(“Y”)) {//this line does a loop until the

// user confirms the data entered is correct

Scanner sc = new Scanner(;//this creates the object

// called sc from the scanner class using the system in from the keyboard to gather data

System.out.println(“Enter bullet weight in grains”);

weight = sc.nextInt();//gets data from user using the sc object

System.out.println(“Enter velocity in feet per second”);

velocity = sc.nextInt();//gets data from user using the sc object

System.out.println(“The Bullet Weight is ” + weight + “\n”);

System.out.println(“The Bullet Velocity is ” + velocity + “\n”);


System.out.println(“Is this correct? (Y)es or (N)o \n”);

choice =;//if the user answers with a capital Y the program moves

// on, otherwise it repeats


System.out.println(“The Bullet Energy is…” + ((velocity * velocity) * (weight) / 450240) + ” foot pounds of energy.”);

//velocity squared times the weight divided by 45240 is the answer in foot pounds



This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply