Write a class that encapsulates the evolution

Assignment Help Basic Computer Science
Reference no: EM13308147

Write a class (and a client class to test it) that encapsulates the evolution of the sales tax rates in the 50 U.S states over the last 10 years. Your only instance variable should be a two-dimensional array of values representing the sales tax rates. Dimension 1 represents the state and dimension2 represents the year. Your constructor can simply be a default constructor, randomly generating the sales tax rates, which should be between 0 and 0.06. You should include the following methods:

a.       A method returning the index of the state that has the biggest average tax rate over the years.

b.      A method returning an array of indexes of the states that have had at least one year with a tax rate less than 0.001

c.       A method returning the highest sales tax rate over the years for a given state (which will be a parameter)

Part 2

1.      Design and code a program including the following classes, as well as a client class to test all the methods coded:

Passenger class, encapsulating a passenger. A passenger has two attributes: a name, and a class of service, which will be 1 or 2.

Train class, encapsulating a train of passengers. A train of passengers has one attribute: a list of passengers, which must be represented with an ArrayList. Your constructor will build the list of passengers by reading date from a file calledpassengers.txt (that you would create). You can assume that passengers.txt has the following format:

<name1>         <class1>

<name2>         <class2>

....

For instance, the file could contain:

James   1

Ben      2

Suri      1

Sarah   1

Jane     2

.....

You should include the following methods in your Train class:

a.       A method returning the percentage of passengers traveling in the first class

b.      A method taking two parameters representing the price of traveling in first and second class and returning the total revenue for the train.

c.       A method checking if a certain person is on the train; if he/she is, the method returns true; otherwise, it returns false.

Sorry if it is disorganized or ugly. The box where you type this in isn't the greatest. Anyways thanks in advance! J

 

Reference no: EM13308147

Questions Cloud

Wholesaling and retailing jewellery nationally all across : Pandora Diamonds and Gems Pty Ltd is a company engaged in the business of importing, wholesaling and retailing jewellery nationally all across Australia.
Find the amplitude of current oscillations in the circuit : A 1-microF capacitor, a 10-Ohm resistor and a 1 microH inductor are connected in series with a sinusoidal signal generator of 10V peak voltage amplitude operating at a frequency ω of 100 rad/s. Find the amplitude of current oscillations in the cir..
Write a program that asks the user to enter a string : Write a program that asks the user to enter a string. Create a pointer called strPtr and print the first character, third character and fifth character from your string using this pointer.
Calculate the maximum shear and indicate in terms of x : a. Determine the shear and moment diagram. b. Calculate the maximum normal stress on the top of the beam, on the bottom of the beam and indicate in terms of x its location.
Write a class that encapsulates the evolution : Write a class (and a client class to test it) that encapsulates the evolution of the sales tax rates in the 50 U.S states over the last 10 years. Your only instance variable should be a two-dimensional array of values representing the sales tax ra..
What is the ratio of the charge to its initial value : A series RLC circuit contains a 2200 ohm resistor, a 14.0 nF capacitor, and a 0.0300 H inductor. what is the ratio of the charge to its initial value
Write a program that calculates the user''s bmi : Write a program that calculates the user's body mass index (BMI) and categorizes it as underweight, normal, overweight, or obese, based on the following table from the United States Centers for Disease Control
Find the magnitude force on each wire : Three parallel wire 5 m long carry each 24 A of current in the same direction. Find the magnitude force on each wire
Analysis of a health and safety accident : A case study analysis of a health and safety accident in the New Zealand workplace. The workplace should be related to your chosen discipline.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Which of the following runs as a dedicated server only

Which of the following runs as a dedicated server only?

  Explain how that characteristic may be exploited

Describe how top-down and bottom-up methods of threat/fault analysis can be used in identifying assets relevant to a scenario. You do not need to be exhaustive but do enough of the analysis to demonstrate you understand the processes.

  Research a specific lapse in professional ethics

Research a specific lapse in professional ethics by an IT professional in the last five (5) years. Summarize the ethical dilemma, and develop a plan in which you would mitigate the vulnerability

  Four consecutive clock pulses

A given FSM has an input w, and an output,z. During four consecutive clock pulses, a sequence of four values of the w is applied. Derive a state table for the FSM that produces z = 1 when it detects that either the sequence w: 0101 or w: 0111 has bee..

  Write the main program to generate random numbers

To compare the performance, you need to write the main program to generate random numbers to populate a large integer array, and then call the subroutine to sort this array. Remember to get the time before and after the bubble sort to measure the ..

  What is the output of the following loop

What is the output of the following loop? System.out.println("+----+"); for (int i = 1; i

  Largest problem can be solved if total execution time given

In general, is it possible to solve arbitrarily large problem in a fixed amount of time, given that unlimited number of processing elements is available? Explain why?

  Describes how you have used abstraction as a strategy

Give an example that describes how you have used abstraction as a strategy and how it was beneficial to you.

  Write a pseudocode statement

Write a pseudocode statement that subtracts the variable downPayment from the variable total and assigns the result to the variable due. Don't use integer as decimal places will be needed.

  What are the practical benefits

What are the practical benefits, if any, of importing a specific class rather than an entire package (e.g. import java.net.* versus import java.net.Socket)?

  Creating a payoff table for decision

Amy decided to select the best option which will minimize her total 36-month cost. Difficult is that Amy is not sure how many miles she will drive over next three years. Create payoff table for Amy's decision.

  What is the purpose of modular design

what's the purpose of modular design ?? why do we break dows circuits into modules and design them independently ?? good answer please

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd