Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  KillingKangaroos.java
Language: JAVA
Code:
KillingKangaroos.java
import java.util.Scanner;
//=============================================================================
public class KillingKangaroos {
//-----------------------------------------------------------------------------
    private static Scanner keyboard = new Scanner(System.in);
//----Chance of killing the kangaroo
private static final double Road_Kill_Probability_Constant = 1.47;
//----The standard width of an australian road is .10 Km
private static final double Width_Of_Roads = .01;
//-----------------------------------------------------------------------------
    public static void main(String[] args){
//----Variables
        double lengthOfSideOfArea, kangaroosInArea, lengthOfRoads,  
        densityOfKangaroos, surfaceAreaOfRoads, kangaroosOnRoad, 
        expectedKangarooDeaths;
//----Gather Data
        System.out.print ("Enter length of area in Km:");
        lengthOfSideOfArea = keyboard.nextDouble ();
        System.out.print ("Enter length of road in Km:");
        lengthOfRoads = keyboard.nextDouble ();
        System.out.print("Enter estimated number of Kangaroos in the area:");
        kangaroosInArea = keyboard.nextDouble ();
//----Perform Calculations
    densityOfKangaroos = kangaroosInArea / (lengthOfSideOfArea * lengthOfSideOfArea);
    surfaceAreaOfRoads = Width_Of_Roads * lengthOfRoads ;
    kangaroosOnRoad = densityOfKangaroos * surfaceAreaOfRoads;
    expectedKangarooDeaths = kangaroosOnRoad * Road_Kill_Probability_Constant;
    
//----Print info
    System.out.print ("Estimated number of kangaroo deaths is :" + expectedKangarooDeaths);
    System.out.print ("this program has been printed by Hunter Hewitt thankyou and careful driving");
    }
//-----------------------------------------------------------------------------
}
//=============================================================================
Comments: