[go: up one dir, main page]

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

Worksheet 3 (Simple Programs)

This document provides instructions and problems for a programming fundamentals worksheet. It includes 14 problems that involve writing programs to: 1) Evaluate arithmetic expressions and determine data types 2) Calculate employee salary 3) Calculate circle area and circumference from radius 3 sentences

Uploaded by

Miki Abera
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views2 pages

Worksheet 3 (Simple Programs)

This document provides instructions and problems for a programming fundamentals worksheet. It includes 14 problems that involve writing programs to: 1) Evaluate arithmetic expressions and determine data types 2) Calculate employee salary 3) Calculate circle area and circumference from radius 3 sentences

Uploaded by

Miki Abera
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Fundamentals to Programming

Worksheet III

Instruction
• First, draw flow charts describing the algorithms that you apply to
solve the following problems and then transform the algorithms into
programs.

1. Compute the value of each legal C++ arithmetic expression. If the


expression is not legal, explain why. Clearly indicate what the data type
of the result of each expression would be.

a) (1.0 / 4) * 6
b) (6 * 3) % 5
c) (3 / 4) * 4
d) (4.0 * 2) % 5
e) ((10 + 5 / 2) / 3)
2. Write a program that implements the following algorithm.
Start
Read the total hours the employee has worked, TotalHours
Read the hourly rate of pay for the employee, HourlyRate
GrossSalary = TotalHours * HourlyRate
Tax = GrossSalary * 0.1
NetSalary = GrossSalary - Tax
Display NetSalary
Stop
3. Write a program that calculates and displays the area and the
circumference of a circle based on its radius entered from the keyboard.

4. Write a program that swaps the values of two variables and displays their
former and current values. The values of the variables are to be entered
from the keyboard.

5. Write a program that tells whether a number entered from the keyboard
is an even or an odd number.

6. Write a program that tells whether a number entered from the keyboard
is a positive number or a negative number or zero.

7. Write a program that tells whether a character entered from the


keyboard is in upper case or in lower case or neither.

8. Write a program that converts a letter entered from the keyboard to its
uppercase or lower case equivalent.

9. Write a program that accepts a character entered from the keyboard and
tells whether it is a digit or a letter or a special symbol.

10. Write a program that converts a temperature given in Fahrenheit into


Celsius and vice verse. The program should distinguish temperature
entered from the keyboard as in degree centigrade or as in degree
Fahrenheit by the letters ‘c/C’ or ‘f/F’ that must be written in front of the

1
numeric values of temperatures. For example:- If the user enters 10 c
or 10 C, the program must understand that the input is in degree
centigrade so it should change to degree Fahrenheit and must display
the temperature as 50 f or 50 F.
11. Write a program that calculates and displays the income tax of a salary
entered from the keyboard. Your program must calculate taxes
according to the following rates:

Up to 200Br 0%
200Br – 600Br 10%
600Br – 1200Br 15%
1200Br – 2000Br 20%
2000Br – 3500Br 25%
3500Br & above 30%

For example:- The income tax of a gross salary of 900 Birr is 85 Birr,
which is calculated as (200*0% + 400*10% + 300*15%)=85 Birr.

12. Write a program that tells the number of days found in the months of a
European calendar. Where the month and the year are to be entered
from the keyboard. Your program must consider leap year condition
along with other conditions.

13. Write a program that computes and displays the next date of a European
calendar date entered from the keyboard. Your program must consider
leap year condition, along with other conditions.
For example:- The next date of 24/11/07 must be computed and
displayed as 25/11/07.

14. Write a program that converts a mark of a course entered from the
keyboard to its corresponding letter-grade based on the following scales.

Mark Grade Mark Grade

>=90 A+ >=55 C+
>=80 A >=45 C
>=75 B+ >=30 D
>=60 B < 30 F
Note that all your programs must provide some mechanisms of
validating appropriate input entries.

You might also like