Your task is to calculate an individual's tax given their income. The tax is calculated using the following table:
0 - $18,200 | Nil |
$18,201 – $37,000 | 19c for each $1 over $18,200 |
$37,001 – $90,000 | $3,572 plus 32.5c for each $1 over $37,000 |
$90,001 – $180,000 | $20,797 plus 37c for each $1 over $90,000 |
$180,001 and over | $54,097 plus 45c for each $1 over $180,000 |
Your task is to add code to this function:
double calculateTax(int income) {
// PUT YOUR CODE HERE (you must change the next line!)
return 42;
}
Add code so that calculateTax returns the person's payable tax.
calculateTax should return a single double.
calculateTax will be given an integer as input.
calculateTax should not call scanf (or getchar or fgets).
calculateTax can assume the income will be positive
calculateTax can assume the income will be less than $2 billion.
calculateTax function should not print anything. It should not call printf.
When you think your program is working you can run some simple automated tests. Make sure you add in test cases of your own.
./test_calculateTax
When you are finished working on this exercise you must submit your work by running submit:
submit q1
It should then print the strictly positive integers, each on a separate line, in the reverse order they occurred.
Match the the example below EXACTLY.
dcc q2.c -o q2 ./q2 Enter a number: 1 Enter a number: 4 Enter a number: 0 Enter a number: 5 Enter a number: -6 Enter a number: 2 Enter a number: -3 Enter a number: 9 9 2 5 4 1
You can assume the input will only contain integers between negative 2 billion and positive 2 billion, one per line.
The number zero is not included as a strictly positive integer.
You can assume your input contains at least one integer.
You can assume your input contains no more than 10000 integers.
You are free to write this program in any way you wish: there is no specific function that you need to implement. Note that your program will need to have a main function.
When you are finished working on this exercise you must submit your work by running submit:
submit q2
Complete the given function, which calculates the range of an array. The function takes in an array and its length as arguments. The range of the array is the difference between its largest value and smallest value.
Your task is to add code to this function:
int arrayRange(int array[], int arrayLength) {
// PUT YOUR CODE HERE (you must change the next line!)
return 42;
}
ExampleYou can assume the input will contain at least one integer.
You can assume the array will only contain integers between -2000000000 and 2000000000.
When you are finished working on this exercise you must submit your work by running submit:
submit q3
Your task is to add code to this function in cardMatch.c:
int cards_match(Card cardDeck[], int cardsLength, Card card) {
// PUT YOUR CODE HERE (change the next line!)
return 42;
}
Note cardMatch.c uses the following familiar data type:
typedef struct card {
Color color;
Value value;
Suit suit;
} Card;
cards_match is given three arguments.
Add code to cards_match so that it returns the number of cards in cardDeck that matches with the given card.
Two cards are matching if at least one of their value, color, or suit are the same.
Furthermore, two cards are also considered matching if at least one of them has a value of ZERO.
When you are finished working on this exercise you must submit your work by running submit:
submit q4
Your task is to add code to this function in insertDescending.c:
struct node *list_descending(struct node *head, int value) {
// PUT YOUR CODE HERE (change the next line!)
return 42;
}
Note list_descending.c uses the following data type:
struct node {
struct node *next;
int data;
};
list_descending is given two arguments.
When you are finished working on this exercise you must submit your work by running submit:
submit q5
Your task is to add code to this function in product_sum.c:
int productSum(struct node *head1, struct node *head2) {
// PUT YOUR CODE HERE (change the next line!)
return 42;
}
Note product_sum.c uses the following data type:
struct node {
struct node *next;
int data;
};
productSum is given two arguments.
When you are finished working on this exercise you must submit your work by running submit:
submit q6
<p>
i am retarded
i have crippling depression
</p>
Tags can also be nested:
<autism>
i am retarded
<big>
i have crippling depression
</big>
nice!
</autism>
However, this is incorrect nesting:
<autism>
i am retarded
<big>
i have crippling depression
</autism>
nice!
</big>
Write code which finds errors in nesting and prints out the line number.
When you are finished working on this exercise you must submit your work by running submit:
submit q7
dcc q8.c -o q8 ./q8 d4 b3 d4 b3 ./q8 d4 a1 d4 b3 a1 d4 c2 a1
When you are finished working on this exercise you must submit your work by running submit:
submit q8