1 Page

mgp00006

Course: CGS 2414, Fall 2008
School: University of Florida
Rating:
 
 
 
 
 

Document Preview

Input Information Program given to the program from an outside source To simplify input, the author provides the JPB package which provides the SimpleIO class To read user input, Use the prompt() method to display a message and leave the cursor at the end SimpleIO.prompt( "Enter temperature: Fahrenheit " ); Then use the readLine() method to obtained the input typed (up until the user...

Register Now

Unformatted Document Excerpt

Coursehero >> Florida >> University of Florida >> CGS 2414

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
Input Information Program given to the program from an ...
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

University of Florida - CGS - 2414
Tracing the Loop public class loop { public static void main(String [] args) { int i = 1; int n = 10;=> while (i < n) { System.out.println( i + " " + i * i
University of Florida - CGS - 2414
Declaring ConstantsUse the final keyword to declare constantsA constant can hold the value of an expression public class FtoC { public static void main(String[] args) { final double FREEZING_POINT = 32.0; final
University of Florida - CGS - 2414
Tracing the Loop public class loop { public static void main(String [] args) { int i = 1; int n = 10; while (i < n) { System.out.println( i + " " + i * i
University of Florida - CGS - 2414
<?xml version="1.0" encoding="UTF-8"?><Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Key>3324e8df45459d4adf0fcc21f0cdb51be628e971.txt</Key><RequestId>F66FC7E7757E380D</RequestId><HostId>CQcGkyN6SAz3aw3lIl2WuQouqvyI
University of Florida - CGS - 2414
CGS 2414Lecture 20ep@cise.ufl.edu
University of Florida - CGS - 2414
Execution (cont.) public class eq { public static void main(String [] args) { String x = "abc"; String y = "cbs"; if ( !x.equalsIgnoreCase(y) )=> System.out.println("na
University of Florida - CGS - 2414
Tracing the Loop public class loop { public static void main(String [] args) {=> int i = 1; int n = 10; while (i < n) i *= 2; System.out.println( "i resul
University of Florida - CGS - 2414
Arc Width / HeightThe dimension passed to the method is the diameter of the arc
University of Florida - CGS - 2414
Assignment OperatorsSet or replace the value of the variable on the left-hand side=Assignment+=Addition and assignment-=Subtraction and assignment*=Multiplication and assignment/=Division and assignment i += 1; / equivalen
University of Florida - CGS - 2414
Tracing the Loop public class loop { public static void main(String [] args) { int i = 1; int n = 10; while (i < n) {=> System.out.println( i + " " + i * i
University of Florida - CGS - 2414
Common Array OperationsFinding the largest or smallest element public class acount { public static void main(String [] args) { int[] arr = { 4, 5, 53, 1}; int largest = arr[0];=> fo
University of Florida - CGS - 2414
Tying the action to the button import java.awt.*; import java.awt.event.*; public class ButtonTest { public static void main(String[] args) { Frame f = new ButtonTestFrame("Button Test");
University of Florida - CGS - 2414
Text FieldsSingle-line text components class MyFrame extends Frame { public MyFrame(String title) { super(title); setSize( 200, 100 ); setLayout( new FlowLayout() ); L
University of Florida - CGS - 2414
Common Array OperationsCounting Occurrences public class acount { public static void main(String [] args) { int[] arr = { 4, 5, 12, 53, 12, 24, 14 }; int cnt = 0;=> for (int i = 0;
University of Florida - CGS - 2414
Common Array OperationsCounting Occurrences public class acount { public static void main(String [] args) { int[] arr = { 4, 5, 12, 53, 12, 24, 14 }; int cnt = 0; for (int i = 0;
University of Florida - CGS - 2414
More About ForThere is no rule for where to declare control variables or how many to use in the loopDeclaring the variable outside (and before) the loop allows use of the variable following the loop (it'll maintain any value possibly set in the l
University of Florida - CGS - 2414
Declaring and Creating ObjectsDeclaring an object creates a reference to an object instead of the object itselfReference: space in memory that points to where the object actually is=> Account my_acct; / object is not cr
University of Florida - CGS - 2414
CGS 2414Lecture 29ep@cise.ufl.edu
University of Florida - CGS - 2414
Curly Braces// I forgot my bat beltpublic class Batman{ public static void main(String args[]) { / who am I? System.out.println("I am Batman"); / output message }}The curly braces delimit the beginning and end of relate
University of Florida - CGS - 2414
CGS 2414Lecture 7ep@cise.ufl.edu
University of Florida - CGS - 2414
<?xml version="1.0" encoding="UTF-8"?><Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Key>e5d50a093f96d6cc9789ccedfb58ecb918267146.txt</Key><RequestId>A240BA88E93A7966</RequestId><HostId>O6W6rW/yqKSLQaQAO+FmahyRvqrx
University of Florida - CGS - 2414
Rewrite with a "do"Much like a while statement except expression and body have switched positions import jpb.*; public class dw { public static void main(String [] args) { int num; do {
University of Florida - CGS - 2414
Writing text import java.awt.*; import jpb.*; public class gtest { public static void main(String [] args) { DrawableFrame df; df = new DrawableFrame( "My Frame" );
University of Florida - CGS - 2414
Tracing the Loop public class loop { public static void main(String [] args) { int i = 1; int n = 10; while (i < n) {=> System.out.println( i + " " + i * i
University of Florida - CGS - 2414
<?xml version="1.0" encoding="UTF-8"?><Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Key>67954ef281cf67b37a99fdfb4367fa5b2ead91d9.txt</Key><RequestId>236DC656EA2A7314</RequestId><HostId>8wLaB57aWE2JBqMIVBxkx25HpN7W
University of Florida - CGS - 2414
Finally.All methods added / generalized account class public class Account { private double balance; public double getBalance() { return balance; } public void deposit( doub
University of Florida - CGS - 2414
Commonly Used Static VariablesThe System class provides a few useful static objectsSystem.in - the standard input streamHandles keyboard inputSimpleIO.readLine() reads input from itSystem.out - the standard output streamHandles displaying ou
University of Florida - CGS - 2414
Tracing the Loop public class loop { public static void main(String [] args) { int i = 1; int n = 10; while (i < n) { System.out.println( i + " " + i * i
University of Florida - CGS - 2414
<?xml version="1.0" encoding="UTF-8"?><Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Key>b0530438c046aa1ef6afa228cf2dec347f0516cd.txt</Key><RequestId>48900C88672DE2B9</RequestId><HostId>e0QaCWTe8akNwtlm8iAIOCv3CDmS
University of Florida - CGS - 2414
Arrays and Loops public class t1 { public static void main(String [] args) { int[] num_array = { 4, 10, 20 }; int i = 0; int sum = 0; while (i < num_array.length)
University of Florida - CGS - 2414
Modifying the Value of a VariableThe assignment operator can be used to both initialize and reassign the value of a variable int i = 0; / initializing the integer i to 0 / our program does stuff with i here i = 32; /