Prerequisites This assignment requires knowledge of the material presented in cl
ID: 3740599 • Letter: P
Question
Prerequisites
This assignment requires knowledge of the material presented in class through week 07 and through sections on classes/objects in the various the textbooks.
Background
The corporate income tax rate (currently a flat 21%) in the United States of America generally has a negative correlation with the existence of any sort of middle class:
We must accept that correlation does not imply causation. However…
Somewhat obviously, a major goal of any U.S.-based corporation is to use every possible accounting trick to plausibly claim that a source of income is not eligible for taxation by the U.S. government. This is exactly what one would expect such an organization to do. After all, a psychopath is as a psychopath does.
Assignment
You shall write a Java program that allows the user to simulate the passage of time until one or more corporations reach what we might call Tax Shelter Nirvana by amassing a certain amount of tax-sheltered money.
Specifically, when executed, your program shall:
Receive the names of corporations involved in this simulation as command-line arguments. Corporation names are guaranteed not to contain whitespace characters. For example, if your main method is in a class called Assignment07, then a command specifying two companies named Apple and WalMart would look like this:
Maintain information about each corporation in an object that contains at least:
The corporation's cash on hand (initially $0)
The corporation's annual taxable income (initially $1 billion)
The corporation's annual tax-sheltered income (initially $0)
Process an arbitrary number of commands as input on standard input. Each command consists of one or three whitespace-delimited tokens, as follows:
taxable name value: Assigns a new amount of annual taxable income for the given corporation. name must be a valid name of a corporation, and value must be a decimal number in the range provided by Java's double type. For example:
sheltered name value: Assigns a new amount of annual tax-sheltered income for the given corporation. name must be a valid name of a corporation, and value must be a decimal number in the range provided by Java's double type. For example:
year: Simulates the passing of one year by adding to every corporation's cash on hand the sum of its current taxable annual income (minus the corporate tax rate of 21%) and tax-sheltered annual income.
Once any corporation achieves more than $10 billion cash on hand (to double precision), they are considered enlightened. The program shall print a line to standard output for each enlightened corporation, in the same order as specified in the command-line arguments, containing at least the name of the corporation. The program shall then exit.
If standard input is exhausted before any corporation achieves enlightenment, the program shall exit with no output.
Note: Your program need not expect nor deal with any unexpected/malformed input, negative incomes, etc.
Examples
A sample executable named cs12j_corporate_tax_shelter_nirvana exists on the server, and replicates the expected behavior of your program.
Here are some examples of expected input and output, using the sample executable:
Command:
Input:
Output:
Command:
Input:
Output:
Command:
Input:
Output:
Suggestions
I used an instance of the following Corporation class to represent each corporation's status. If you use this as well, consider adding a constructor that sets up the initial values for cash on hand, etc.
In your main method, you will probably want to create an array of type Corporation (or whatever class name you choose) that is the same length as the command-line argument array (usually args):
Explanation / Answer
Hi,
Below are the required Corporation.java and Tax_Shelter_Nirvana.java(Tester) files. The tester program takes corporations in Commnd line Args and stores in an array of Corporation objects(as indicated in question). Then it takes the input from console and as per input performs intended actions. If the input is year then for each corporation, simulate method is called, which adds the sum of taxable and sheltered incomes to cash on hand. However, in this case one assumption is that the line only contains year keywords. After the input is exhausted, for each corporation check if cash on hand is greater than 10 billion by calling checkEnlightenement() method. If it returns true, print output for that corporation.
I have ran the program against the input scenarios provide and it is working as expected. Let me know if you have any questions.
Corporation.java
Tax_Shelter_Nirvana.java