Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
CS200 Lab 1: The Programming Cycle
For each part complete the instructions, and turn-in a hardopy of your source code files, the 
outputs from running your programs, your pseudocode for Part C, and your answers for Part D.
Part A.
1.	

 Create a directory on your P: drive to save your work in.
2.	

 Download a copy of the file Output.class from the class website and put a copy into the 
directory you created in step 1. This compiled Java file will give your program a way to perform 
output.
3.	

 Launch JGrasp.
4.	

 Choose File - New - Java.
5.	

 Choose File - Save. Navigate to the directory you created in step 1. Name the file Hello (the 
file extension .java will automatically be appended). Note: the file name is case sensitive (e.g., 
“hello” and “Hello” are considered different words).
6.	

 On the back of this page is a Java program. Type this program in exactly as it appears, 
changing only the date and substituting your name for Kevin’s. Note that Java programs are case 
sensitive. Use the tab key to indent/align your source code as it appears in the original.
7.	

 Now attempt to compile your program by pressing the green cross button on the toolbar 
above the editor window (note that this will also automatically save your file). Messages from 
the compiler will be displayed in the pane below the editor window. Successful compilation will 
produce the following output:
----jGRASP exec: javac -g Hello.java
----jGRASP: operation complete.
Any other output indicates a compilation error occurred. In that case, look at the line indicated in 
the first error message and compare it closely to the corresponding line on the back of this page. 
You may have to look at nearby lines to find the error. After correcting the first error message, 
attempt to recompile again. Continue until there are no error messages.
8.	

 Now run your program by pressing the toolbar button with a red person on it (next to the 
compile button). This should display a dialogue box with “Hello World!” in it.
9.	

 Notice that the output in the dialogue box also appears in the pane beneath the editor 
window. Copy-and-paste this output into a text file using the editor of your choice.
10.	

Print-out and turn-in hardcopies of your Hello.java file and the output you saved in step 9.
page 1 of 2 
// File: Hello.java
// CS200 Lab 1A
// Author: Kevin Sahr
// Created: September 20, 2006
public class Hello
{
! public static void main (String [] args)
! {
! ! Output.showMessage("Hello world!");
! } // method main
} // class Hello
Part B. Write, compile, and execute a Java application program with the class name MyRiddle 
that outputs the following riddle and answer: 
“How many programmers does it take to change a lightbulb?”
“None, that’s a hardware problem.”
Your program must use two method invocation statements, one for the riddle and one for the 
answer. (Hint: refer to Part A for the sequence of steps that will be required).
Print-out and turn-in hardcopies of your source code file and the output from running your 
program.
Part C. Write, compile, and execute a Java application program with the class name FullName 
that outputs your first, middle, and last names. Your program must use three method invocation 
statements, one for each part of your name. Submit pseudocode for your solution, your source 
code file, and a copy of the output generated by running the program. Handwritten pseudocode 
will not be accepted.
Part D. Note the following method invocation statement:
Vorpal.bling(“SOU”);
Answer the following questions about this statement:
1. What is the name of the method being invoked?
2. In what class is that method defined?
3. What argument(s) does the method take?
Handwritten answers will not be accepted.
page 2 of 2