ITEC 1011 A,B
Week 8 Lab Instructions
November 2,3 2000

 

Java Programming

Instructions

1.

Programming Challenge.  Write a Java program called Fun.java that works as follows.  Prompt the user to enter a number.  Input the number as a string, convert it to an integer, and then output the message Java is fun! n times, where is n is the number entered.  Finish the program by outputting the message Thank you.  Include comment lines at the top of the source file stating your name, student number, and the date.  A sample dialogue follows:

            PROMPT>java Fun
     Please enter a number: 2
     Java is fun!
     Java is fun!
     Thank you
     PROMPT>

Hint:  The “pieces” of the Java language required for this programming challenge are found in numerous example programs in the Java Primer.  If you have followed the instructions in the labs thus far, you have already compiled and executed all the example programs in Chapters 1-4.  If you’re not sure how to get started with this programming challenge, have a peek at DemoKeyboardInput.java and JavaIsFun.java.  Everything you need to know is found in these programs.  For discussion on these programs, see the Java Primer.  DemoKeyboardInput.java is found in Chapter 2, Figure 10, and JavaIsFun.java is found in Chapter 3, Figure 13.

Once the program is working properly, copy and paste the source code into the body of an e-mail message and send it to ta1011a@mathstat.yorku.ca or ta1011b@mathstat.yorku.ca. 
(Make sure the source code includes the required comment lines.) 
Use the following subject line:

            nov5: lastname studentnumber

Finally, make a backup copy of your source file and name it Fun.bak.  This is just a precaution.  Hopefully you won’t need this.

 

2.

Homework.  If you haven’t already done so, read Chapters 1-4 in the Java Primer.  Compile and execute all the example programs in these chapters.

 

Also, please make sure you take a few minutes to read the technote on the errout utility program.