Lab Assignment #1: Simple Java

Due by 11:59PM on Wednesday, Jan 27.


Reading Assignment

Read Chapter 2 of the text Computing Concepts with Java Essentials. This covers material on numbers, strings, input/output, and variables.

Please read this entire assignment before beginning!


Getting Started

The ccj package: The book refers to a collection of Java classes written by the authors. In order to use these classes in your programs, you must download their definitions.

To download the ccj package, click on the link below that says "download ccjinst.exe". If netscape tries to open this file, you can also right-click on the link and select "save as" - and save the file in your floppy. Open your floppy from "my computer". You should see an executable file called ccjinst with an icon that looks like an arrow coming up from a red book. Double click on this file. This will open the self-extractor. Make sure the installation path is your floppy (A:\) and hit ok. This will create a directory called ccj in your floppy and extract all the ccj library files. Click okay when it says that extraction was successful. After the successful extraction, you may delete the ccjinst file.

Download the ccjinst executable

If you have trouble using ccjinst, you can follow this link and manually download each of the java files of the ccj library and put them in a folder called ccj in your floppy.


Comments

At the top of each file that you submit, include the following information in program comments:

/*
Your Name
Your ID Number
Your Username
Which Assignment
Your Laboratory Section Number
Your AI's name(s)
*/

In general, you should fully document your code with meaningful comments. Avoid decorative comments such as "set x to 5", which do not really help to clarify the code.


In-Lab Work

Students are reminded that attendance at lab is required.

During Lab, with the assistance of your AI, you will develop a program to solve the following problem.

You have some spare change in your wallet, but you don't want to go through the trouble of finding out exactly how much money you have. You dump all the change on the table and separate them by quarters, dimes, nickels and pennies. You want to now write a program that will help you figure out exactly how much money you have.

There are many ways to perform this task. You should write the program in such a way that the program asks you for the number of each type of coin, and then tells you the total amount of money you have.

It is good if you make mistakes in the lab. Your AI will help you in figuring out your compilation and runtime errors if you can't figure them out yourself.

Name your file Coins.java and submit it using the subject that you are given in the lab.

Lab Assignment

This is your actual lab assignment for the week. You will write and debug two programs. Your AI may discuss strategies for solving these problems, but there will not be time in lab for you to complete the programs.

Please take care to use the exact filenames specified in the problems below.

  1. In a certain class students take two midterm exams and a final exam. Each exam is graded out of 100 points. The midterms each count 30% of the students grade and the final counts 40%. Write a program that prompts the user for the three exam scores and then calculates the numeric grade (out of 100) for the course.

    Here is a sample run. The user input is given in green italics.

    Enter grade on the first midterm: 75
    Enter grade on the second midterm: 93
    Enter grade on the final exam: 98

    Your final score is 89.6

    Save your program in a file named Grade.java.

  2. Exercise P2.10, Page 81 of Horstmann. Save your program in a file named Gas.java.
  3. Exercise P2.9, Page 80.
    Save your program in a file named Change.java.

Submitting Your Lab Assignment

For this lab, you should submit three files:

Do not submit .prj or .class files. Only the three files named above should be submitted.

In order to submit files, click on the following link to send mail to:

a201@cs.indiana.edu

with the following Subject:

lab1

and then Attach your program files to the e-mail message. You may attach all files in the same message, but you don't have to. You can submit the three exercises in separate e-mails if you wish. Do not type anything in the body of the message! You must use the filenames specified in the assignment and you must attach the files to the mail message.

As before, you will receive an e-mail reply informing you of whether or not your submission was accepted.


Last modified: Thu Feb 4 21:55:23 EST 1999
asengupt@cs.indiana.edu