Design and development of significantly sized software using top-down design and bottom-up implementation. Dynamically allocated data, object-oriented programming, architecture of memory, basics of language translation, and basics of algorithm analysis. Development of simple graphical user interfaces. Prerequisite: CS 110 (grade of C or better).

Lab 2 - Introduction to Classes and Operators - (50 points)



Due date: 2/11/2016 at 11:59pm

Objectives



  • Familiarize yourself with Java
  • Use basic constructs such as conditionals

Part 1: Change Dispenser Program



For this part of the lab, you will write a program (ChangeDispenser.java) that will take in a total amount from the user (such as $7.25) and then will ask the user to payment amount. The user will then enter a payment amount such as ($10.00). Your program will then do the following:

  • Display the change that needs to be returned to the user ($2.75 in our example).
  • Display the minimal set of notes and coins required to return the change to the user. (In our example, it would be 2 $1 notes, and 3 quarters)

Part 2: Insurance Calculator Program



For this part of the lab, you will write an insurance calculator program that will take input from the user in terms of their age, education level, marital status, and their employment status and display their monthly premium to them. Create an Individual class that contains the following data attributes

  • age
  • education level - One of High School, Bachelor's, or Master's
  • marital status
  • employment status - One of Student, Unemployed or Employed
  • insurance payment - This is initialized to $100.0
Make sure that the class has a constructor, getters/setters, and a toString() function.

The getInsurance() method returns the monthly premium for a specific individual and will be computed as follows:

  • If the age of the individual is less than 22 or greater than 70, then their insurance is higher by 25% per month.
  • If the education level is Bachelor's then the insurance is 10% lower and if it is Master's then the insurance is 20% lower.
  • If the individual is married, then their insurance is 20% lower.
  • If the occupation is specified as student, then the insurance is 10% higher. If the occupation is specified as unemployed, then the insurance is 5% lower.
The user input is obtained in the InsuranceCalculator class. In this class,

  • Asks the user to enter their respective data. The data obtained using the Scanner is stored in appropriate variables.
  • Once all the data is collected, a new Individual object is created.
  • The individual's premium is then displayed by calling the getInsurance() method.

Submitting the assignment



  • In your local directory under username/cs112/ make a directory (mkdir) called lab2. Put all your files in that directory. Step out of that directory by typing cd .. and type svn add lab2 followed by svn commit -m "message".
  • The Java files for this project will be ChangeDispenser.java, Individual.java and InsuranceCalculator.java.
  • Make sure to include a README.txt file
  • You can resubmit the assignment as many times as you want. It will upload a new copy of the files to the SVN repository. We will only grade the one that is closest to 11:59pm on the due date.