Introduction to Programming with C++ (variables, operators, decision making structures)
Weight: 5%
Submission instructions:
- Create a cpp file for each question
- Create a pdf file containing the screenshot of all programs and their results
- Name the file as your lastname_student id
- Compress the files using zip or other tools and name the file as your lastname_student id Submit the zip file on Moodle
- Do not submit executable files
- All submissions must be done through Moodle
Questions:
- (15 marks) Write a program that asks the user to enter three integers and prints the sum, product, and division, and average of these numbers. Here is an example of the execution of the program:
*****************************************
Enter the first number: 10
Enter the second number: 5
Enter the second number: 20
*****************************************
The results are:
Sum: 35
Product: 1000
Average: 11.66
*****************************************
- (15 marks) Write a program that takes a Celsius temperature from the user and converts it to Fahrenheit and Kelvin. The output should look like this:
Celsius Fahrenheit Kelvin
4 38.2 277.15
- (20 marks) Write a program that takes three integers and outputs them in an ascending order, i.e., for the smallest to the largest number. For example, if the user enters 45, 100, 30, the program should output 30, 45, 100.
- (25 marks) Write a program that takes the final grade of a student and returns the corresponding letter grade using the following marking scheme:
- A+ grade >=90
- A 85 <= grade < 90
- A- 80 <= grade < 85
- B+ 75 <= grade < 80 B 70 <= grade < 75
- C+ 65 <= grade < 70
- C 60 <= grade < 65
- C- 55 <= grade < 60
1/2 COEN 243 Winter 2021
- D+ 50 <= grade < 55
- D 45 <= grade < 50
- D- 40 <= grade < 45
- F grade < 40
- (25 marks) In tax-year 2020, Canadas income tax brackets are given as below:
- 15% on the first $48,535 of taxable income, plus
- 5% on the next $48,534 of taxable income (on the portion of taxable income over $48,535 up to $97,069), plus
- 26% on the next $53,404 of taxable income (on the portion of taxable income over $97,069 up to $150,473), plus
- 29% on the next $63,895 of taxable income (on the portion of taxable income over $150,473 up to $214,368), plus
- 33% of taxable income over $214,368
Write a program that takes an income value from the user and calculates the income tax and net income (income tax) according to the above brackets.
Test your program with two values of 255000 $ and 132000$ incomes.
2/2
Reviews
There are no reviews yet.