Starting from:

$30

Assignment 1 - Introduction to Programming with C++

COEN 243 
Assignment 1 - Introduction to Programming with C++

Weight: 4%
Submission instructions:
- Create a cpp file for each question
- Compress the files using zip or other tools
- Submit the zip file on Moodle
- Do not submit executable files
- All submissions must be done through Moodle
Questions:
1. (20 marks) Write a program that asks the user to enter two integers and prints the difference,
product, division, average and the summation of square of these two numbers. Here is an example of
the execution of the program:
*****************************************
Enter the first number: 10
Enter the second number: 5
*****************************************
The results are:
Difference: 5
Product: 50
Division: 2
Average: 7.5
Sum of square: 125
*****************************************
2. (20 marks) Write a program that takes the income of an employee and calculates the corresponding
net income and tax portion based on the following information:
• tax = 45%: income >= 110,000 $
• tax = 35%: 90 K <= income < 110 K
• tax = 25%: 70 K <= income <90 K
• tax = 15%: 40 K <= income <70 K
• tax = 5%: income <40 K
COEN 243 – Summer 2023
2/2
3. (25 marks) Write a program that converts 5 given values in kilograms to grams and vice versa. It asks
the user to enter 5 integer values and one character as the unit for each value (‘G’ (grams) or ‘K’
(kilograms)). If the user enters ‘G’ as the unit, the program shows the corresponding value in
kilograms and vice versa. Here is an example of expected output (values in gray are entered by the
user):
values Unit Equivalent
6 k 6000 gr
75 G 0.075 kg
9.5 k 9500 gr
650 G 0.65 kg
7500 G 7.5 kg
4. (15 marks) Write a program that takes an integer as input and returns whether it is a prime number
or not.
5. (20 marks) Write a C++ program that asks the user to enter his/her height in meters and his/her weight
in kilograms and calculates the BMI index based on the following formula:

More products