Start by making a copy of the time program. Recall that to copy a file you use the Unix cp command. Assuming that you have been using the suggested names, the following commands should do the trick:
cd cd CS113 cp HW2/Time.java HW3/Time.javaYou modified program should cover the following cases:
$ java Time 72 1 hour and 12 minutes $ java Time 121 2 hours and 1 minute
$java Time 180 3 hours $java Time 45 45 minutes $java Time 60 1 hour
$ java TempChange London 54.4 54.7 Paris 55.8 56.3 Madrid 59.0 59.1 Paris had the biggest change: 0.5In this case:
java TempChange Dallas 91.1 92.2 Houston 94.4 94.6 Atlanta 92.2 92.5 Dallas had the biggest change: 1.1000000000000085This is okay! While clearly not great, but it is not a bug in your program! This is not something you need to address here but we will talk about it later in the semester. Note that when specifying the names of cities that have spaces in them, you can put quotes around the name and Java will treat it as a single String, for instance: java TempChange "New York" 78.0 78.9 Philadelphia 81.1 81.5 Boston 77.4 77.5 New York had the biggest change: 0.9000000000000057 Keep in mind that your program needs to identify the largest change, not the largest increase, so for instance:
java TempChange Seoul 68.6 67.6 Beijing 71.0 71.2 Hanoi 74.1 74.5 Seoul had the biggest change: 1.0Hint! You can use the Math.abs function to get the absolute value of a number. For instance:
double y = Math.abs(x);will set y to the absolute value of x. You may assume that all nine program inputs are provided in the correct order and are of the expected types, i.e. Strings for the city names and doubles for the temperatures, but your program should be able to handle negative numbers, which are allowed. Additionally, you may assume that the temperature changes for the three cities are all distinct, i.e. you don't have to handle the case where two cities have the same change in temperature.
Income | Rate |
---|---|
0--11,000 | 10% |
11,001--44,725 | 12% |
44,726--95,375 | 22% |
95,376 + | 24% |
11,000 * 10% (44725-11000) * 12% (95376-44725) * 22% (100000-95376) * 24% or 11000*.1 + 33725*0.12 + 50651*0.22 + 4624*0.24 or 1100 + 4047 + 11143 + 1109 or 17399So although the last bit of income is taxed at 24% the average tax rate is only 17%. (yea?)
To rephrase
With a marginal tax rate, you pay that rate only on the amount of your income that falls into a certain range. To understand how marginal rates work, consider the bottom tax rate of 10%. For single filers, all income between $0 and $11,000 is subject to a 10% tax rate. If you have $11,200 in taxable income, the first $11,000 is subject to the 10% rate and the remaining $200 is subject to the tax rate of the next bracket (12%). (from https://smartasset.com/taxes/current-federal-income-tax-brackets)When doing the calculations at each step, the result should be an integer (as shown above). To get the result of an integer (the income) times a double (the tax rate) back into an integer, you can do the following:
double rate = 0.22; int income = 100; int tax = (int)(income*rate);Putting the "(int)" into the last line above tells Java that you really mean for the result of the multiplication to be an integer. Without this assurance from the programmer, the Java compiler will fail at this line.
Write a program called IncomeTax that takes one integer from the command line. Interpret that integer as the total taxable income. The program should then calculate the tax and print the tax owed. You may assume that the thing given on the command line is an integer, but you should check that it is a valid income.
Here are some more examples:
$ java IncomeTax 100000 17399 $ java IncomeTax 50000 6307 $ java IncomeTax 5000 500 $ java IncomeTax 77101 12269
You should have 4 files in your HW2 directory: Time.java, TempChange.java, IncomeTax.java and Readme. (You might also have .class files.)
cd cd CS113 mkdir HW3Once you have made the HW3 directory in Unix, open a terminal on you own computer and in that terminal use "cd" to navigate to the directory containing your work for this assignment. Assuming you use the same directory structure on your own computer and in the lab, this process can be accomplished with the following commands
cd cd CS113 cd HW2Then use the scp command to copy each of the files you want to submit from your computer to the lab. For example:
scp Readme UNIX_NAME@goldengate.cs.brynmawr.edu:CS113/HW3/ReadmeAs always, when you read "UNIX_NAME" put in your UNIX user name. Also, with each scp command you will need to enter your UNIX password.
cd cd CS113 /home/gtowell/bin/submit -c 113 -d HW3 -p 3In response to the submit command you should see a series of messages ending with:
Submitting archive... Submission complete! Submission timestamp is 2023-08-08-15-30-28-EDT.