Computer Science 523
Advanced Programming

Summer 2014, The College of Saint Rose

Lab 1: Java Basics
Due: 4:30 PM, Tuesday, June 3, 2014

This first lab is intended primarily as review for those of you who are Java programmers, and a chance to adapt your programming knowledge to Java for those who aren't.

You are to work individually on this lab.

Getting Set Up

To get your BlueJ environment set up for this week's lab assignment, start BlueJ and choose "New Project" from the "Project" menu. Navigate to your folder for this course and choose the name "Lab1" (no spaces) for the project.

Create a document where you will record your answers to the lecture assignment and lab questions. If you use plain text, call it "lab1.txt". If it's a Word document, you can call it whatever you'd like, but when you submit, be sure you convert it to a PDF document "lab1.pdf" before you submit it.

Lecture Assignment Questions

We will usually discuss these questions at the start of class on the lab due date, so no credit can be earned for late submissions of lecture assignment questions.

LA Question 1: Gaddis Checkpoint Exercise 2.22, p. 62 (2 points)

LA Question 2: Gaddis Checkpoint Exercise 3.12, p. 129 (2 points)

LA Question 3: Gaddis Checkpoint Exercise 4.9, p. 206 (2 points)

Practice Programs

Practice Program: Your first task is to compute and display the final cost, including sales tax, for the purchase of a single article of clothing. In New York State, clothing is taxable only if it costs $110.00 or more.

Your input is the price of a single article of clothing (which you would specify in dollars and cents form like "25.99"). If the cost is under $110.00, the output would be "No tax on that!". But if it is $110.00 or more, you will need to compute the sales tax and output a message such as "With sales tax of $16.00, that will cost you $216.00." (assuming a purchase of $200.00 and a tax rate of 8%).

Write a Java program in a class called ClothingTax that solves the above problem. (10 points)

Notes and requirements:

Practice Program: Your next task is to create a rudimentary password quality checker. It's so rudimentary that all it does it judges the quality of the password on the length of the password string.

Your input is a candidate password string. Your output is a statement about the quality of the password. Passwords whose length is less than 5 characters is reported as "Poor", 5-8 characters as "Fair", 9-12 characters as "Good", and 13 or more as "Great".

Write a Java program in a class called PasswordChecker that solves the above problem. You may use either terminal I/O with a Scanner and System.out.println calls or dialog boxes with JOptionPanes. (8 points)

Programming Assignment

You are to write a program GradeSummary.java that will be responsible for reading in the names and grades for a group of students, then reporting some statistics about those grades. The statistics to be gathered are the number of scores entered, the highest score and the name(s) of the student(s) who earned that score, the lowest score and the name(s) of the student(s) who earned that score, and the average score for the class.

So if the names and scores are as follows:

Luke 76
Hermione 99
Wally 34
Linus 99
Penny 25

then your program would print output:

There were 5 scores, averaging 66.6.
The lowest score was 25 by Penny.
The highest score was 99 by Hermione and Linus.

The program is worth a total of 45 points, as broken down in the table at the end of this document.

Question 1: Gaddis defines a term for a special value that is used to terminate a loop, as the special name "done" does here. What is that term? (1 point)

Question 2: By using the special name "done" in this manner, we have placed a restriction on the valid names our students may have. What name would cause a problem for our program? (1 point)

Question 3: Describe in a few sentences your approach to the "correct initialization" described in the bullet item above. Why did you choose the initial values you did and how do they ensure that the first score entered will become the new high and low score without treating that as a special case. (2 points)

Submitting

Before 4:30 PM, Tuesday, June 3, 2014, submit your lab for grading. There are four things you need to do to complete the submission: (i) Copy your file with the answers to the lecture assignment and lab questions into your project directory. Be sure to use the correct file name. If you prepared your answers in Word, export to a PDF file and submit that. (ii) Upload a copy of your lab (a .7z or .zip file containing your project directory) using Submission Box under assignment "Lab1". (iii) Demonstrate the execution of your programs for your instructor. (iv) Hand a printout of the Java files that make up the programming assignment (not practice programs) to your instructor. (2 business day grace period for demos and printouts).

Grading

This assignment is worth 75 points, which are distributed as follows:

> FeatureValueScore
Lecture assignment questions 6
ClothingTax correctness 10
PasswordChecker correctness 8
GradeSummary input loop 7
GradeSummary error checking 4
GradeSummary reports total number of scores 4
GradeSummary reports average score 5
GradeSummary reports high/low scores 5
GradeSummary report names of all high/low scorers 6
GradeSummary output formatting 2
GradeSummary uses named constants 2
GradeSummary comments 5
GradeSummary naming conventions 3
GradeSummary formatting 2
Using all correct file names 2
Lab questions 4
Total 75