Write program that computes the amount of income tax

Assignment Help MATLAB Programming
Reference no: EM132245466

Introduction to Computing for Psychology Assignment Questions -

Q1. Write a MATLAB program that computes the amount of income tax a person needs to pay according to the following table:

Income Range ($)

Base Tax ($)

Percentage of Excess

0.00 - 14,999.99

0.00

15

15,000.00 - 29,999.99

2,250.00

18

30,000.00 - 49,999.99

5,400.00

22

50,000.00 - 79,999.99

11,000.00

27

80,000.00 - 149,999.99

21,600.00

33

150,000.00 - 199,999.99

49,500.00

36

>= 200,000.00

72,000.00

40

For example, if a person's income is $20,000.00, the income tax the person needs to pay is $2,250.00 (base tax for the second range) plus 18% of the excess income over $15,000.00 (that is, 18% of $5,000). Therefore, the total tax due is $2,250.00 plus $900.00, which is $3,150.00.

Your program should first prompt the user to input an income (with the prompt of "Please enter your income for 2018: "), then based on the amount and the above table calculate the total amount of income tax. Your program should output to the command window the total amount of tax as follows:

Your total 2018 income tax is: x

where x is the calculated total amount of tax with two digits after the decimal point. For example, if the calculated amount is $3,150, the value should be displayed as 3150.00. If the income entered by the user is negative, your program should output to the command window: invalid income.

Q2. A vector is given by: v=[6, 3, -9, 10, 5, 0, -8, 11, -5]. Write a MATLAB program that uses a for loop and nested if statements to divide each positive even element of v by 2, multiply each positive odd element of v by 2, and square (i.e. raise to power 2) each of its negative elements. Then it should output the new vector to the screen as:

The new vector is: 3 6 81 5 10 0 64 22 25

Q3. Write a Matlab function, called testprime, that takes one input argument and uses a for-loop and rem function to check whether its argument is a prime number. testprime(x) should return 1 if x is a prime number and 0 otherwise. Your testprime function must behave as shown below:

>> help testprime

testprime checks if its argument is a prime

testprime(x) is 1 if x is a prime, 0 otherwise.

Author:<your name, student #, email>

>> testprime(12)

ans =

logical

0

>> testprime(7)

ans =

logical

1

>> 

Hint: To get a logical 1 and logical 0 as output of your function, see 'help true' and 'help false'.

Q4. A vector is given by x = [49 7 59 87 65 13 5 22 11 77 23 97 44 99]. Using conditional statements, loops and your testprime function from previous step write a MATLAB program that creates two vectors from x. The first vector (call it P) contains elements of x which are prime numbers, and the second vector (call it N) contains the non-prime elements of x. In both P and N, the elements are in the same order as in x. At the end of the program, display P and N as follows:

The prime vector is: 7 59 13 5 11 23 97

The non-prime vector is: 49 87 65 22 77 44 99

Q5. Consider the following table that contains the midterm and final exam marks of a group of students and their student IDs:

Student ID

Test 1

Test 2

Final

1201

66

75

70

1210

69

60

77

1215

82

85

68

1220

92

89

95

1235

49

58

54

1238

75

87

90

1239

81

65

62

1240

40

39

30

1255

65

70

55

1257

67

83

80

1270

48

53

60

1271

68

78

55

The above data are stored in an Excel file (named scores.xls), which can be downloaded from the Assignment page of the course moodle site.

All term tests and final marks are out of 100. The total mark of a student is a weighted sum of the student's term tests and final marks. The weights of Test 1, Test 2, and Final are 25%, 30%, and 45% respectively.

Write a MATLAB program that does all of the following in the specified order:

a) Read the student IDs, Test 1, Test 2 and Final marks in the scores.xls file into a matrix (named M) in MATLAB. Note that you are not allowed to type the values into a matrix.

b) Compute the total score of each student using the weighted sum of the student's term tests and final marks as described above. Then display all the marks in the command window as follows:

StudentID

Test 1

Test 2

Final

Total

1201

66

75

70

70.5

1210

69

60

77

69.9

1215

82

85

68

76.6

1220

92

89

95

92.5

1235

49

58

54

54.0

1238

75

87

90

85.3

1239

81

65

62

67.7

1240

40

39

30

35.2

1255

65

70

55

62.0

1257

67

83

80

77.7

1270

48

53

60

54.9

1271

68

78

55

65.2

Note that the student IDs, term test marks and final marks are displayed as integers, but total marks are displayed with one digit after the decimal point. Note that you are not allowed to type the total marks into your program. The values must be computed. This also applies to the following steps.

c) Compute the average of the total scores over all the students, and display the computed average to the command window as follows: The average total score is: 67.6

Note that the average score is displayed in the same line as the string "The average total score is", and one and only one digit after the decimal point is displayed.

d) Compute the number of students whose final marks are better than their Total, and display the result in the command window as follows: The number of students whose final mark is better is: 6

e) Compute the number of students whose final marks are worse than their Total, and display the result in the command window as follows: The number of students whose final mark is worse is: 6

f) Compute the number of students whose total mark is above the average total mark calculated in Step c), and display the result in the command window as follows: The number of students above total average is: 7

g) Compute the number of students in each letter grade. The letter grades and their corresponding numeric total scores are described in the following table:

F

E

D

C

B

A

A+

[0, 40)

[40, 50)

[50, 60)

[60, 70)

[70, 80)

[80, 90)

[90, 100]

The results should be displayed as follows: 

The number of A+ students is: 1

The number of A students is: 1

The number of B students is: 3

The number of C students is: 4

The number of D students is: 2

The number of E students is: 0

The number of F students is: 1

What to hand in - You need to submit your assignment electronically. Please submit four MATLAB script files:

a3q1.m (the script file for Question 1)

a3q2.m (the script file for Question 2)

testprime.m (the function file for Question 3)

a3q4.m (the script file for Question 4)

a3q5.m (the script file for Question 5)

For Question 3, testprime function, include your name, student number, and email as indicated in the problem. 

For questions with multiple parts use comments to indicate which part(s) of the question the commands that follow are addressing.

Attachment:- Assignment File.rar

Reference no: EM132245466

Questions Cloud

Why do we study international juvenile justice : Assume the role of a researcher for a nonprofit that examines international juvenile justice systems and/or youth violence.
Explain who is liable for daves negligence for causing : During his previous employment at another company, Dave had been involved in a workplace fistfight with a fellow employee, resulting in criminal charges.
A policy that helps ensure workers are properly classified : A policy that helps ensure workers are properly classified by including specific action items that will be required of employees and management.
How can a reputation be repaired if at all : How can the employer properly investigate without damaging the reputation of the accused? What if the accused where wrongfully accused?
Write program that computes the amount of income tax : EECS 1570 - Introduction to Computing for Psychology Assignment Questions, Lassonde School of Engineering, Canada. Write program that computes income tax
What is the pretrial process : What is the pretrial process? List and briefly define each step of the pretrial process.
Speculate on how the outcome of the customers suit against : Two stockbrokers, in clear violation of the rules of their employer, sold worthless stocks to unsuspecting customers.
Who in the business entity would typically create : The company president (who is also the owner) inherited the company from his father, and thus has never started a business.
Research and investigate a real court decision : To challenge you to think about the business implications of the case, and specifically how the case will impact an actual organization.

Reviews

len2245466

2/28/2019 3:46:40 AM

Please put your name, student number and yorku email address in the first few lines of EACH script file as comments (that is, each of these few lines should start with % so that MATLAB will treat them as comments and ignore these few lines when executing your program). For Question 3, testprime function, include your name, student number, and email as indicated in the problem.

len2245466

2/28/2019 3:46:32 AM

For questions with multiple parts use comments to indicate which part(s) of the question the commands that follow are addressing. For instance you may use a loop to answer several parts of the same question. This assignment is worth 6% of your final grade. Hint: To get a logical 1 and logical 0 as output of your function, see ‘help true’ and ‘help false’. Note that the student IDs, term test marks and final marks are displayed as integers, but total marks are displayed with one digit after the decimal point.

Write a Review

MATLAB Programming Questions & Answers

  Finite difference method

Use the finite difference method to calculate the temperature at the point specified since it is easier.

  Determine the necessary shell temperature

In a shell-and-tube heat exchanger, one fluid passes through a central tube while another fluid flows through an outer shell in the opposite direction. The purpose is to heat the fluid passing through the central tube.

  Find the integral of a function at an arbitrary location

Write a Matlab function to perform numerical integration of a set of evenly spaced data points using the trapezoidal rule

  Compute the speed of single-stage planetary gear train

Write a MATLAB function [speed] = planetary (N, emesh, first, last, arm) that computes the speed of a given link in a single-stage planetary gear train.

  Calculate and plot the error in the numerical derivative

Write a program to calculate and plot the error in the numerical estimate of the derivative.

  Create the graph using matlab functions

Create the graph, which contains a piecewise function where a line exists in the first interval, a parabola in the second interval, and the sine function in the third interval.

  Develop a simulation program

Develop a simulation program

  Create a vector in matlab

Create a three dimensional diagram of function.

  Open a named pipe and to read data from the pipe

Open a named pipe and to read data from the pipe in matlab

  Write the commands that will create the matrix

Write the commands that will create the matrix.

  Lagrange interpolating polynomial of degree

Lagrange interpolating polynomial of degree

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