



|
|
CS1 Course Site
|
Programming Challenge Archive
General Problems Solving
Starting Five
|
|
|
JavaApplication --
StartingFive
// General Information
// ---------------------------------------------------
// File: StartingFiveApp.java
// Type: java application file
// Date: Mon Sep 18, 2000
// Name: Kara Becker
// Line: Compute the average height of the new starting l+
ineup.
// Application Description
// ---------------------------------------------------
/*
Determine the average height of the new starting lineup +
with the given information.
*/
// Required Packages
// ---------------------------------------------------
import blue.io.*;
// Application Class
// ---------------------------------------------------
class StartingFiveApp
{
static public void main (String args[])
{
//Determine the height of the five original basketball pl+
ayers in inches.
double origAvgHeight = 75.5;
double totalOrigAvgHeight = origAvgHeight * 5;
//Determine the height of the starting lineup without the+
6 foot player.
double sixFtPlay = 72.0;
double heightOfFour = totalOrigAvgHeight - sixFtPlay;
//Determine the height of the starting lineup with the ne+
w 7 foot player.
double sevFtPlay = 84.0;
double heightOfFive = heightOfFour + sevFtPlay;
//Determine the average height of the new starting lineup+
.
double newAvgHeight = heightOfFive / 5;
//Display the result.
IO.print("The average height of the starting five is ");
IO.print(newAvgHeight);
IO.print(" inches.");
IO.println();
}
}
// Demo
// ---------------------------------------------------
/*
$ javac StartingFiveApp.java
$ java StartingFiveApp
The average height of the starting five is 77.9 inches.
$
*/
|
|
|