Compute income tax based on old income

Assignment Help Basic Computer Science
Reference no: EM132270188

1. Make an R program to compute the income tax based on the old income tax rate:

Under $25,000 = 15%

$25,000-74,999 = 25%

$75,000-149,999 = 28%

$150,000-299,999 = 33%

$300,000 and over = 35%

The main program creates a random sample incomes between $1,900 to $500,000 of 15 people. The function set.seed(256) is to set the random number seed to 256. The random number generator will generate the sequence of random samples specific to the seed. A fixed seed will allow you getting the SAME random samples for every run. That way, you will have an easier time to debug your program. This, by the way, demonstrates to you that they are not real random samples. They are what is called pseudo-random numbers. The function sample ( ) does the actual work. Check the help manual on sample ( ) to find out more.

The 15 random samples between $1,900 and $500,000 is then assigned to vector incomes. In the next statement:

income.table = income.tax(incomes)

the assignment statement calls a user defined function income.tax( incomes) by passing the incomes vector to that function. Consequently, income.tax ( ) will return a data frame with two columns: incomes and rate of each person. The data frame is assigned to income.table, which allows you compute the tax for each person by multiplying the incomes and rate. Then the mean and standard deviation and the histogram of incomes of this 15 people sample are computed and displayed.

1. Write the income.tax ( ) function that computes and creates the data frame. YOU ARE NOT ALLOWED TO USE LOOPS. (Hints: sapply( ).)

2. After (1) is working, change the sample size from 15 to 150000. Repeat the execution. Compare the histogram of this run to the one you got in 1. Explain your results in a Word document. Save it as prog7.docx and save your R script as incometax.R

Question 2:

This exercise is to make sure you know the basic construct and flow of control of nested if-else statements. I added line number to the LeapYear.R that you did in Prog1 as follows:

1. year = 1900         # This is an inline comment. We assign the integer 1900 to variable name year

2. answer = 'Not a Leap Year'    #initialize year, assuming it is not a leap year

3. if (year %% 4 == 0)            # if the year is fully divisible by 4

{

4. If ( year %% 100 == 0)       # if the year is fully divisible by 100

{

5. if ( year %% 400 == 0)    # and year is fully divisible by 400, then it is a leap year

6. answer = 'Leap Year'    

}     # not a leap year

7. else answer = 'Leap Year'   # if it is fully divisible by 4 but not 100, then it is a leap year

}

8. paste(year, answer)

Fill in the execution step (line numbers) in the table below for the following years: 1900, 1992, 2000, 2016, 2018,2019, 2020. I illustrated the execution for year 2018. 

Leap Yr = No

Explanations: line 1, year = 2018; line 2, answer = 'Not a Leap Year'; line 3, "if" statement is false. It drops completely from the if-else block (from line 3 to 7) to line 8 since answer remains as 'Not a Leap Year'.

Reference no: EM132270188

Questions Cloud

How would assessment be different for other type of customer : Select a consumer product of personal interest-one that you have purchased within the past six months. It can be anything, just as long you are familiar.
Third normal form : To take this motley crew of tables to Third Normal Form (3NF), we must now take 2NF tables and eliminate all transitive (i.e., hidden) dependencies.
Unplanned service interruptions : DHCP is a very promiscuous service, and this can cause unplanned service interruptions if not configured properly. Explain.
What is the state constitution like : What is the state constitution like? In what ways is it similar to and different from the federal one?
Compute income tax based on old income : 1. Make an R program to compute the income tax based on the old income tax rate:
Explain the marketing strategy behind the pricing : Cost of goods sold (COGS) is the cost of the products and/or services sold to customers. In general, a retailer's cost of goods sold includes the cost.
How has artificial intelligence changes : How has artificial intelligence changes over the past decade?
Trade space for time and trade time for space in algorithmic : Please discuss and give an example of a scenario when it is important to trade space for time and trade time for space in algorithmic design.
Identify stakeholders and roles : Imagine you have been asked to present at a town hall meeting. You are presenting the details of a new local policy that is being proposed.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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