public class Traffic
extends java.lang.Object
Constructor and Description |
---|
Traffic() |
Modifier and Type | Method and Description |
---|---|
static void |
main(java.lang.String[] args) |
static void |
printNumber(double d,
int minimumWidth,
int fractionDigits)
Print a number to
System.out , using a specified format. |
static double |
simlights(int offset,
int span,
double arrivalProb,
int travelTime,
int totalTime) |
public static void main(java.lang.String[] args)
public static double simlights(int offset, int span, double arrivalProb, int travelTime, int totalTime)
public static void printNumber(double d, int minimumWidth, int fractionDigits)
System.out
, using a specified format.d
- the number to be printedminimumWidth
- the minimum number of characters in the entire outputfractionDigits
- the number of digits to print on the right side of the decimal point
Precondition:
fractionDigits
is not negative.
Postcondition:
The number d
has been printed to System.out
.
This printed number is rounded to the specified number of digits on the
right of the decimal. If fractionDigits
is 0, then only the
integer part of d
is printed. If necessary, spaces appear
at the front of the number to raise the total number of printed
characters to the minimum. Additional formatting details are obtained
from the current locale. For example, in the United States, a period is
used for the decimal and commas are used to separate groups of
integer digits.java.lang.IllegalArgumentException
- Indicates that fractionDigits
is negative.
Example:
printNumber(12345.27, 8, 1);