Due: 9am, April 16, 2008.
This assignment will give you practice at writing Java programs where:
Solve problems 2, 4, 6, 7, 8, 11, 14 and 15 in the Java Programming Exercises.
A few hints. Most of what you need can be found on the "java examples" web page and in the blue class reader:
/* * ================================================================== * FourNumbers.java: Prompt user for four floating point numbers, * print each number, and then the smallest and largest values. * ================================================================== */ import java.lang.Math; import java.io.*; public class FourNumbers { public static void main( String args[] ) { double dA, dB, dC, dD; String sLine; // Prompt user for numbers dA, dB, and dC. .... details removed .... System.out.println("Please enter dA, dB, dC and dD"); .... details removed .... // Print each of the numbers .... .... details removed .... // Ccmpute and print largest/smallest values.... .... details removed .... } /* * ============================================================ * Method getTextFromConsole(): Read line of text from keyboard * * Input : None. * Output : String sLine -- character string of keyboard input * ============================================================ */ public static String getTextFromConsole() { String inLine = ""; ... get details from java examples web page .... return inLine; } }
Notice that the source code for the method getTextFromConsole() needs to be "inside" the class FourNumbers.
Note. For each problem, hand in a copy of your program source code and a script of I/O for typical program usage. To create a script, type something like:
prompt >> script output-file
Now all input/output on the screen will be echoed to the file "output-file". To terminate the script, type:
prompt >> exit
Now print "output-file" and hand it in.
Developed in March 2008 by Mark Austin
Copyright © 2008,
Department of Civil and Environmental Engineering, University of Maryland