0% found this document useful (0 votes)
51 views

Week 4 Lab Exercises PDF

The document provides instructions for two exercises in a computer science lab session. Exercise 1 involves writing a program to calculate an employee's weekly salary based on hours worked and pay rates. Exercise 2 involves writing a program to convert between Fahrenheit and Celsius temperatures based on user input, and testing the program's results against hand calculations. Students are asked to submit their source code for evaluation.

Uploaded by

Abdul Aziz Turdi
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)
51 views

Week 4 Lab Exercises PDF

The document provides instructions for two exercises in a computer science lab session. Exercise 1 involves writing a program to calculate an employee's weekly salary based on hours worked and pay rates. Exercise 2 involves writing a program to convert between Fahrenheit and Celsius temperatures based on user input, and testing the program's results against hand calculations. Students are asked to submit their source code for evaluation.

Uploaded by

Abdul Aziz Turdi
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/ 1

Sultan Qaboos University

College of Science
Department of Computer Science
COMP2002, Spring 2011
Week 4 Lab Exercises

Exercise 1

Write a C++ program to compute and display a person’s weekly salary as determined by the
following conditions: If the number of hours worked is less than or equal to 40, the person
receives RO 5/- per hour, otherwise the person receives RO 200/- plus RO 7.5/- for each hour
worked over 40 hours. The program should request the number of hours worked as input and
display the weekly salary as output with 3 digits after the decimal point.

Exercise 2

a) Write a C++ program that reads a number followed by one space and then a letter. If the
letter following the number is f, the program should treat the entered number as a
temperature in Fahrenheit, convert the number to the equivalent Celsius temperature and
print a suitable display message. If the letter following the number is c the program
should perform the opposite conversion (from Celsius to Fahrenheit). If the letter is
neither f nor c the program should print a message that the data entered is incorrect and
terminate. Use the following formulas for converting between Fahrenheit and Celsius:
5 9
Celsius  ( Fahrenheit  32) and Fahrenheit  Celsius  32
9 5
Use 2 digits after the decimal point when displaying the converted temperature.

b) Compile, link and execute your program.

c) Test the correctness of your program by comparing its results with results from hand
calculations.
d) Submit your source file named lab4_xxxxx.cpp on Moodle before the end of the lab
session (replacing xxxxx with your student ID).

You might also like