public class WriteVertical
extends java.lang.Object
WriteVertical Java application illustrates recursive
methods that write the digits of a number vertically.
Java Source Code for this class:
http://www.cs.colorado.edu/~main/applications/WriteVertical.java
| Constructor and Description |
|---|
WriteVertical() |
| Modifier and Type | Method and Description |
|---|---|
static void |
main(java.lang.String[] args)
The main method prompts the user for a number that is then printed
in two different ways using recursive methods.
|
static boolean |
query(java.util.Scanner input,
java.lang.String prompt) |
static void |
superWriteVertical(int number)
Print the digits of an integer vertically.
|
static void |
writeVertical(int number)
Print the digits of a non-negative integer vertically.
|
public static void main(java.lang.String[] args)
args - not used in this implementationspublic static boolean query(java.util.Scanner input,
java.lang.String prompt)
public static void writeVertical(int number)
number - the number to be printed
Precondition:
n >= 0. The method does not check the precondition, but
the behavior is wrong for negative numbers.
Postcondition:
The digits of number have been written, stacked vertically.public static void superWriteVertical(int number)
number - the number to be printed
Postcondition:
The digits of number have been written, stacked vertically.
If number is negative, then a negative sign appears on top.