Lab1Therapist

Lab1Therapist - ECE309 Lab 1 Therapist(Spring 2010 Teaching...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ECE309 Lab 1 - Therapist (Spring 2010) Teaching Points: • How to write a C program in Java • Creating and accessing arrays • String compare • Keyboard input • Disk file output In this first lab, we will use the NotePad-and-DOS-window process to develop our Java program, as introduced in the InstallingEclipse.html document that you used to write the HelloWorld program to test your Java installation. We will delay the introduction of the high-level Eclipse development environment until the second lab, to demonstrate that writing a Java program can be very much like writing a C program. A sophisticated development environment is not required, and writing a simple Java program can be simple indeed. Initializing your Java development environment. These instruction are for a Windows environment. Instructions for the subsequent labs will reference Eclipse procedures, and will therefore be platform-independent. Open the NotePad editor and begin by creating the class declaration line and the main() method: public class Therapist { public static void main(String args) { } } Do an initial "save-as" to your Java directory. (Be sure and use quotes around the file name "Therapist.java" so NotePad doesn't append a .txt file type.) Open a DOS window and navigate to the Java directory. Type: javac Therapist.java on the command line to run the javac.exe Java compiler to compile your program. You should get the command line back with no comment (a clean compile). Now type: java Therapist to run the java.exe JVM (Java Virtual Machine) which in turn will load and run your program. Again, you should just get the command line back with no comment as your program loads, executes (and does nothing) and terminates. For the rest of the development of your program, you can go back and forth between these two windows to change and compile and run your program. Note that, in the DOS window, you can press the up-arrow key to recall previous command lines. Do this to avoid retyping the commands to compile and run your program. In the NotePad window, you can now just select "Save" (vs. "Save-as") on the Edit menu to save your code prior to a recompile. By the way, you can terminate a running Java program the same way you terminate a C program: by entering ctrl-C in the DOS window where the program is running. (Don't expect your user to do this, however!) Write all your code for this program inside the main() method. Part 1 - Therapy! The Therapist program converses with the user using the keyboard and console to answer questions. 1. Begin by writing a series of System.out.println(); statements which announce your program as the on-line therapy system. Tell your user to type "EXIT" when they wish to terminate their session. Then tell the user they may enter a question for the therapist to answer. Instruct the user that their question should be phrased such that it can be answered with a YES or NO answer (such as "Will I feel better soon?" or "Should I be more outgoing to people at work?" work?...
View Full Document

{[ snackBarMessage ]}

Page1 / 16

Lab1Therapist - ECE309 Lab 1 Therapist(Spring 2010 Teaching...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online