QuestionQuestion

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:
java Assignment07 Apple WalMart
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:
taxable WalMart 10e9
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:
sheltered Apple 3e9
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.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

public class Assignment07 {

// Main method for program execution
public static void main(String[] args) {
    // Store number of arguments
    int n = args.length;
    // Create array of company names
    String[] companies = new String[n];
    // Create array of cash balances
    double[] cash = new double[n];
    // Create array of taxable annual incomes
    double[] taxable = new double[n];
    // Create array of tax-sheltered annual incomes
    double[] sheltered = new double[n];
    // Set default values in arrays
    for (int i = 0; i < n; i++) {
      companies[i] = args[i];
      cash[i] = 0.0;
      taxable[i] = 1e9;
      sheltered[i] = 0.0;
    }
    // Construct Scanner to read standard input
    Scanner s = new Scanner(System.in);
    // Execute program in a loop, while standard input remains:
    while (s.hasNext()) {
      String param = s.next();...

By purchasing this solution you'll be able to access the following files:
Solution.java.

$40.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats