0% found this document useful (0 votes)
11 views2 pages

Assignment One C++

The document outlines three programming assignments in C++. The first assignment involves creating a program that compares three real numbers and displays whether they are equal or shows the largest. The second assignment is a payroll system that calculates various financial components based on employee input, while the third assignment requires a menu-driven program to perform calculations such as sum, average, and even/odd checks using a switch statement.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Assignment One C++

The document outlines three programming assignments in C++. The first assignment involves creating a program that compares three real numbers and displays whether they are equal or shows the largest. The second assignment is a payroll system that calculates various financial components based on employee input, while the third assignment requires a menu-driven program to perform calculations such as sum, average, and even/odd checks using a switch statement.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Fundamentals of Programming Flow of control

Assignment one
1. Write a C++ program which accepts the values of three real numbers, compares them and if all or
two of the numbers are equal, display “All or two of the numbers are equal”, otherwise display the
largest of all.
2. Write a C++ code which generates a simple payroll system, the program should perform the
following:
a. Accept the ID of an employee
b. Accept Basic Salary of an employee
c. Set house allowance=300birr where Basic salary of an employee is <2808 and 500birr
where Basic salary of an employee is >=2808
d. Calculate Gross earning as sum of Basic Salary and House allowance
e. Calculate Pension as 4% of the employee’s basic salary
f. Calculate income tax as follows

Income tax =0 where Gross Earning <=150


Income tax= (Gross Earning *10%)-15 where Gross Earning is between 151 and 650
Income tax= (Gross Earning *15%)-47.5 where Gross Earning is between 651 and 1400
Income tax= (Gross Earning *20%)-117.5 where Gross Earning is between 1401 and 2350
Income tax= (Gross Earning *25%)- 235 where Gross Earning is between 2351 and 3550
Income tax= (Gross Earning *30%)-412.5 where Gross Earning is between 3551 and 5000
Income tax= (Gross Earning *35%)-662.5 where Gross Earning is >5000
g. Calculate Total deduction as sum of Pension and Income Tax
h. Calculate Net pay of an employee as the difference between Gross Earning and Total
Deduction.
i. Display the following
ID
Basic Salary
House Allowance
Gross Earning
Pension
Income Tax
Total Deduction
Net Pay

Page 1 of 2
Fundamentals of Programming Flow of control
3. Using switch statement write a C++ program Which has the following menu
a. Press S to calculate and display the sum of three real numbers.
i. Accepts the values of three real numbers
ii. Calculates their sum
iii. Displays their sum
b. Press A to calculate and display the Average of the three numbers.
i. Accepts the values of three real numbers
ii. Calculates their average
iii. Displays their Average
c. Press N to check the number is even or odd”.
i. Accepts the value of an integer number
ii. Checks whether the number is even or odd
iii. If the number is even it displays “The number is even” otherwise it displays “The
number is odd”.
d. Press E to exit.
e. If the user inserts a character different from the cases given above the program should
display “Invalid Menu” and the program should be terminated.

Page 2 of 2

You might also like