Java I
Jonah Warrenjonah@parsons.edu
http://a.parsons.edu/~java2004
Lab 9
Code from class...
HelloWorld.java
VariableWorld.java
ArgumentWorld.java
ArgumentWorld2.java
ArraysAndLoops.java
ControlStatements.java
ControlStatements2.java
Homework 9
(Please email me if you have any questions or problems)- Read photocopied chapter 1 from Sams Teach Yourself Java in 21 Days.
- Look over these two websites. They will be very important in you learning Java.
- http://java.sun.com/docs/books/tutorial/java/index.html - a tutorial site for Java basics and syntax.
- http://java.sun.com/j2se/1.4.2/docs/api/ - the Java API.
- Set up Java on your computer. Look at this site for reference. Let me know as soon as possible if you have problems.
- Be sure you can run and compile the HelloWorld Program. Remember, your file name for this program has to be: HelloWorld.java. Let me know as soon as possible if you have problems.
class HelloWorld { public static void main(String args[]) { System.out.println("Hello World!"); } } - Email the following 2 programs to me by next week.
- create an array of 100 integers representing grades on a test.
- initialize those 100 array values to random numbers between 50 and 100.
- using this data, write a program called GetArrayValues.java that allows the user to enter in a numbers from 0 to 99 when running the program (called arguments) from the command line. For each value the user enters, print out the corresponding value stored in the array. Print out an error message if any number the user enters is not between 0 and 99. You will need to use args.length to determine how many numbers have been entered. An example output is below:
D:\>java GetArrayValues 89 32 76 22 Your entered 4 numbers. Position 89 in the array holds the score 58. Position 32 in the array holds the score 73. Position 76 in the array holds the score 81. Position 22 in the array holds the score 65.
- using the same data, write a program called GradeInfo.java that prints out the following information. The output should look similar to whats below. The last information is a bonus question.
The scores in the array are: 65, 89, 65, 45, 64, 72.... The highest score was: 98 The lowest score was: 64 The average score was: 78.32 The grade breakdown was as follows: There were 28 A's. There were 18 B's. There were 22 C's There were 18 D's. There were 14 F's. (BONUS!)The most common score was 73. 4 people got 73.