



|
|
Byron's CSC212 Web Site
|
Programming Challenge Archive
General Problems Solving ( Basic Programming Apps )
Starting Five
|
|
|
JavaApplication --
Starting Five
// General Information
// ---------------------------------------------------
// File: StartingFiveApp.java
// Type: java application file
// Date: Wed Sep 20, 2000
// Name: Byron Bahr
// Line: Compute the Starting Five average height.
// Application Description
// ---------------------------------------------------
/*
Compute the average height of the starting five
when a 6 foot player is replaced by a 7 footer.
*/
// Required Packages
// ---------------------------------------------------
import blue.io.*;
// Application Class
// ---------------------------------------------------
class StartingFiveApp
{
static public void main (String args[])
{
//Define the given information
double averageHeightStartingFive = 75.5;
//Compute the total height of the starting Five
double totalHeightStartingFive =
averageHeightStartingFive * 5;
//Compute the total height with 7 footer
//substituted for a 6 foot player
double sevenFooter = 12.0 * 7.0;
double sixFooter = 12.0 * 6.0;
double newTotalHeightStartingFive =
totalHeightStartingFive
- sixFooter + sevenFooter;
//Compute the Average Height of the
//New Starting Five
double newAverageHeightStartingFive =
newTotalHeightStartingFive / 5.0;
//Print the Result
IO.print ("The Average Height of the Starting Five i+
s ");
IO.print (newAverageHeightStartingFive);
IO.print (" inches.");
IO.println ();
}
}
// Demo
// ---------------------------------------------------
/*
The Average Height of the Starting Five is 77.9 inches.
*/
|
|
|