Description
Lab Exercise #2 – Java I/O
1. Install the Java version 8 JDK .
• Review the document “Installing Java SE 8 and Eclipse” and follow the directions to install Java JDK on your laptop.
• Read the Eclipse Quick Start Guide for instructions on using Eclipse
2. Practice using Eclipse and the Java RTE
• Download JavaMain.java which is attached to this lab in Blackboard. Note that it is a .zip file – you will need to double-click on the .zip file and “extract” the file to get to the .java file. Note – you can edit the code via Notepad (Start/Accessories/Notepad) or Textpad (Start/Textpad)and save it – for example – on your C: drive as JavaMain.java in directory CST8110Labs.
• Note – you might not feel like you understand all of the statements in this program. We will learn how they all work over the next month.
• Follow the instructions in the Eclipse Quick Start Guide (and that was demonstrated in lecture class) to load this JavaMain.java and run it.
o The program should prompt you to enter 10 numbers and then should display the sum and average of the numbers you entered.
o Specifically:
Create a new project called Lab2(New/Project)
In the project, create a new Class (New/Class) called
JavaMain.java (note that this name is case-sensitive!)
Run the program (this will compile and run the program)
• Ask your neighbor, or lab professor if you are having any problems.
3. Modify JavaMain.java
• You need to modify JavaMain.java so that it produces the following output in the EXACT format illustrated (including blank lines and new lines).
• This means you will be changing the statements between the { } using only input statements (Scanner statements), output (print or println statements) and arithmetic statements.
• Red values indicated number entered by the user. Blue values are displayed by your program.
• When you have the program working as displayed below, demonstrate it to your lab professor.
Sample output:
CST8110 – Lab Exercise 2 – Java I/O 1 of 2
This program will produce a printout of three multiples of a number. Enter the number: 12
The first three multiples of 12 are:
12
24
36
Another Sample output:
This program will produce a printout of three multiples of a number. Enter the number: 20
The first three multiples of 20 are:
20
40
60
Another Sample output:
This program will produce a printout of three multiples of a number. Enter the number: -5
The first three multiples of -5 are:
-5
-10
-15
YOU WILL KNOW YOU ARE DONE THIS LAB WHEN YOU HAVE:
• Have Installed Java
• Ran JavaMain.java successfully through Eclipse
• Made changes to JavaMain.java as indicated, and
• Demonstrated your modified JavaMain.java to your lab professor.
CST8110 – Lab Exercise 2 – Java I/O 2 of 2
Reviews
There are no reviews yet.