Vous êtes sur la page 1sur 4

OBJECT ORIENTED PROGRAMMING 1 (JAVA)

Type Lab Quiz MIDTERM LAB QUIZ


Due 2 Hours
Weighting 20

ASSESSMENT TASK
[READ ALL THE INSTRUCTIONS VERY CAREFULLY BEFORE YOU SUBMIT]

Write a java application that calculates and displays the property tax for N property owners.

 N should be declared as a constant and it should be equal to the largest digit of your student
ID number
 E.g. if your ID number is 15-10380-1 then N should be equal to 8 and you can
declare it as final int N=8

The property tax is based on the assessed value of the property as shown below in Table-1.

Assessed Value of the Property Tax


$10000 or less $0.0 (no tax)
Over $10000 but not more than $100000 1% tax

Over $100000 but not more than $300000 3% tax


Over $300000 but not more than $500000 4% tax
Over $500000 5% tax

Table-1: Assessed Value of the Property and Tax

 The application should ask the user to enter the name of the property owner and the
assessed value of the property for each owner (total N owners) and calculate the
property tax.
 The application should display the message with tax and the value of the property after tax
as shown in the example below.
 At the end of the Nth owner, a receipt with total tax, largest tax and average tax should be
displayed.
 The total tax is calculated by adding the tax amount for all owners.
 The largest tax is calculated by finding the largest amount from tax paid by N
owners.
 The average tax is calculated by dividing the total tax with the number of owners.
INPUT & OUTPUT FORMAT

The format for your input and output must be same as given in example below.

Example for N=3 (Note that a loop should be used for reading the input and displaying the output)
Enter the name for Owner 1: Tim Pointing
Enter the value of the property for Owner 1: 9500
Hello Tim, your tax is $0 and the value of the property after tax is $9500.

Enter the name for Owner 2: Amy McDonald


Enter the value of the property for Owner 2: 200000
Hello Amy, your tax is $6000 and the value of the property after tax is $194000.

Enter the name for Owner 3: Rick Hilton


Enter the value of the property for Owner 3: 600000
Hello Rick, your tax is $30000 and the value of the property after tax is $570000.

------------------Receipt for Total Tax, Largest Tax and Average Tax------------------


Total tax is $36000
Largest tax is $30000
Average tax is $12000
------------------------------------------------------------------------------------------------------

The application should be user-friendly by displaying appropriate welcome and exit messages.
The application should use the following classes and methods.

public class Owner {


//declare constants
//declare variables
//declare constructor
//declare & define all methods including get and set methods
}

public class OwnerTest {


final int N=8;

public static void main(String[] args){


//create object
//get name, tax and value of the property after tax
//print output as shown in the example
}
}
2. Create a new class called “City” that can be used to keep track of location information for a
given city. Your class should include the following – be sure to comment your class
appropriately:

a. private String name


b. private double lon (for longitude)
c. private double lat (for latitude)
d. Appropriate setters and getters for the properties
e. A constructor that accepts a name, lon and lat value and stores them in the instance
variables for the object
f. A method that reports the current position of a city. Here’s a method header to get you
started:
public void report()

g. A method that computes the distance from the lon and lat of one city to the lon and lat of
another city. Use the standard distance formula to compute this value (let’s pretend that
the cities lie on a flat plane and not on a sphere!) Here’s a method header to get you
started:
public double distanceFrom(City otherCity)

Create a new class called “CityDistance”. Do the following in this class::


a. Prompt the user to enter in a number of cities (i.e. How many cities do you want to
create?)
b. Next, ask the user to enter in the name, lon and lat for each city. Note that you will
probably need to use two scanners since you are asking for both String and double data.
Create a new City object and store it in an array that is designed to hold objects of type
City (i.e. City[] myCities)
c. Iterate through your array of Cities and ask each city to report its position.
d. Iterate through your array of Cities and compute the distance from each city to each
other city. Ensure that you do not calculate the distance from a given city back to itself
(i.e. no need to compute distance between NYC and NYC – the result will be zero) —
Here’s a sample running of your program.
How many cities? 3
City # 1
Enter name: NYC
Enter longitude: 50
Enter latitude: 75

City # 2
Enter name: Chicago
Enter longitude: 25
Enter latitude: 10

City # 3
Enter name: LA
Enter longitude: 0
Enter latitude: 50

--------

City: NYC is at: 50.0, 75.0


City: Chicago is at: 25.0, 10.0
City: LA is at: 0.0, 50.0

NYC is 69.6419413859206 units away from Chicago


NYC is 55.90169943749474 units away from LA
Chicago is 69.6419413859206 units away from NYC
Chicago is 47.16990566028302 units away from LA
LA is 55.90169943749474 units away from NYC
LA is 47.16990566028302 units away from Chicago
WHAT & HOW TO SUBMIT
You need to upload through your VUES account. Your submission should contain all files:
SUBMISSION STEPS:
1. Create a Directory/Folder with your ID (ex: 15-10380-1)
2. Put all the files into that Folder
3. Upload the zipped format of that Folder

Vous aimerez peut-être aussi