Sei sulla pagina 1di 6

# LABORATORY EXERCISES

ITC 33 using C++ Machine Problems: Prelim Period Part I 1. Create a C++ program that would input two numbers and compute and display the sum, difference, product and quotient. 2. Create a C++ program that would input a value of temperature in degree Celsius and convert the temperature in degree Fahrenheit and degree Kelvin. Formula: Fahrenheit = (9/5) * Celsius + 32 Kelvin = Celsius + 273 3. Create a C++ program that would input value of temperature in Degree Fahrenheit and output its equivalent in Degree Celsius Formula: Celsius = 5/9 * (Fahrenheit 32) 4. Create a C++ program that would input five values of numbers and output the average of five numbers. 5. Create a C++ program that would input a value of money in Pesos denomination and output its equivalent in Dollars. Conversion Factor: 1 dollar = 53.25 Pesos 6. Create a C++ program that would input value of the Radius of a Circle and output the Diameter, Circumference and Area of a Circle. Pi = 3.1416. Formula: Diameter = 2 * Radius Circumference = 2 * Pi * Radius Area = Pi * Radius * Radius 7. Create a C++ program that would input the value of he base and height of a Triangle and output the Area of the Triangle. Formula: Area = * Base * Height 8. Create a C++ program that would input a student name, course, student grade in quiz, seatwork, laboratory exercises, assignment and prelim exam. Compute and output the Prelim Grade. Prelim Grade = Quiz * 25% + Seatwork * 10% + lab. Exercise * 20% + Assignment * 5% + Prelim Exam * 40% 9. Create a C++ program that would input a value of measure in inches and output its equivalent in measure feet. Conversion Factor: 12 inches = 1 foot 10. Create a C++ program that would input an integer and output its square and cube; Example: 52 = 25 53 = 125 Input an integer: 5 <enter> The square of a 5 is 25 The cube of 5 is 125

Prepared by: MR. ROEL RICHARD C. TRABALLO Faculty Member Jose Rizal University Computer Science Department

Page 2

LABORATORY EXERCISES
CSC 25 using C++ Machine Problems: Prelim Period Part II 1. Create a C++ program that would input the following data: Student Number, Student LastName, Student FirstName, Prelim Grade, Midterm Grade, Final Grade. Compute and output the Semestral Grade using the formula below. Semestral Grade = 25% of Prelim + 25% of Midterm + 50% of Final 2. Create a C++ program that would input the following data: Employee Number, Employee LastName, Employee FirstName, Rate per hour, Number of Hours Worked. Compute and output the Gross Pay. Gross Pay = No. of Hours Worked * Rate per hour 3. Create a C++ program that would input the following data: Employee Number, Employee LastName, Employee FirstName, Rate per hour, Number of Hours Worked. Compute and ouput the Gross Pay, SSS Deduction, Tax Withhold, Total Deduction, Net Pay Gross Pay = No. of hrs worked * rate per hour. SSS Deduction = 5% of Gross Pay Tax Withhold = 10% of Gross Pay Total Deduction = SSS Deduction + Tax Withhold Net Pay = Gross Pay Total Deductions 4. Write a C++ program that would input a number and evaluate if the number is a Positive or Negative or Zero. If the number is positive display the message POSITIVE NUMBER, if negative NEGATIVE NUMBER, and if zero display the message ZERO. 5. Write a C++ program that would input a students final grade from 50-100. Evaluate the Final grade and display the Point Equivalent based on the table below. Indicate also the remarks if it is Passed or Failed. Final Grade 98 100 95 97 92 94 89 91 86 88 Equivalent 1.00 1.25 1.50 1.75 2.00 Final Grade 83 85 80 82 77 79 75 76 74 & below Equivalent 2.25 2.50 2.75 3.00 5.00 (FAILED)

6. Write a C++ program that would input a password and test if the password is correct and display the message Password Accepted otherwise, display Invalid Password. (Note: Password is jru or JRU) 7. Write a C++ program that would input a year code and output year level. Input => Year Code Output => Year Level 1 First Year next line Freshmen 2 Second Year next line Sophomore 3 Third Year next line Junior 4 Fourth Year next line Senior Note: Using if..else statement and year code is in character type. 8. Using swichcase statement of #10. Prepared by: MR. ROEL RICHARD C. TRABALLO Faculty Member Jose Rizal University Computer Science Department

Page 3

LABORATORY EXERCISES
CSC 25 using C++ 9. Write a C++ program that would input a course code and output its equivalent course; Input => Course Code Output => Course A or a Accounting B or b Banking and Finance C or c Computer Science D or d Dentistry E or e Engineering else Invalid Course Code Note: Using if..else statement. 10. Using switchcase statement of #12 11. Write a C++ program that would input the following data: Student Name, Average, Tuition Fee and output Total Tuition Fee. Formula: Total Tuition Fee = Tuition Fee Discount If average is: 95 100 100% discount 90 94 25% 85 89 10% 84 and below no discount 12. Write a C++ program that would input Employee Name, Rate per hour, No. of hours worked and will compute the daily wage of an employee. If the number of hours worked exceeds eight hours add 30% to each excess hours as overtime rate. Formula: Daily Wage = Rate per hour * No. of hours worked + OT pay

Prepared by: MR. ROEL RICHARD C. TRABALLO Faculty Member Jose Rizal University Computer Science Department

Page 4

LABORATORY EXERCISES
CSC 25 using C++ Machine Problems: Prelim Period Part III 1. Write a C++ program that would input a users choice based on the table below: Choice Input the following Compute & Output C for Circle Radius of a Circle Area = r2 S for Square Side of Square Area = s2 R for Rectangle Length & Width of a Rectangle Area = lw T for Triangle Base & Height of a Triangle Area = 1/2 bh 2. Write a C++ program that will compute for the net income of a particular employee. You have to accept name, position, and number of days worked. The position has three categories: if Manager, rate per day is P500; if Supervisor, P400; if Employee, P300. Then after accepting the rate per day, compute gross = rate per day * no. of days worked, compute for the bonus, if gross is >= 8000, bonus = 1000; if gross>= 5000, bonus = 750; if gross >= 3000, bonus = 500; if less, bonus = 0; compute for the deductions: SSS is always 10% of gross; Medicare is always P100; and TAX, if gross >= 7000, tax = 15% of gross; if gross >= 4000, tax = 10% of gross, if gross >=2000, tax = 5% of gross. Then, compute for Net Income = gross + bonus total deduction. Then, display the net income. Sample Output: Name: Richard <enter> <m> Manager <s> Supervisor <e> Employee Position: s <enter> Rate: 400 No. of Days Worked: 15 <enter> Gross: 6000 Bonus: 750 Deduction: Tax: 600 SSS: 600 Medicare: 100 Total Deduction: 1300 Net Income: 5450 3. Write a C++ program that would output the following numbers. 1, 2, 4, 7, 11, 16, 32, 39, 47, 56, 66 4. Write a C++ program that would output the following Fibonacci numbers: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144 5. Write a C++ program that would input a number and output the sum of the number from 1 up to the number inputted. Example: if 4 is inputted the sum is 10 i.e.: 1 + 2 + 3 + 4
if 10 is inputted the sum is 55 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10

6. Write a C++ program that would input a number and output its factorial. Example: if 4 is inputted the factorial is 24 i.e.: 4 * 3 * 2 * 1 if 0 is inputted the factorial is 1 1 if 7 is inputted the factorial is 5040 7 * 6 * 5 * 4 * 3 * 2 *1 Prepared by: MR. ROEL RICHARD C. TRABALLO Faculty Member Jose Rizal University Computer Science Department

Page 5

LABORATORY EXERCISES

## And the winner is: FPJ

10. Write a C++ program that would input 10 grades and output the total passed and total failed. 11. Write a C++ program that would input 10 scores and output the Highest and Lowest score. 12. Write a C++ program that would output 10 X 10 multiplication table. 13. Write a C++ program that would display a multiplication table based on the inputs coming from the user. Example: Input no. of column and row: 5 4 Input no. of column and row: 6 3 Prepared by: MR. ROEL RICHARD C. TRABALLO Faculty Member Jose Rizal University Computer Science Department

Page 6

LABORATORY EXERCISES
CSC 25 using C++ 1 2 3 4 2 4 6 8 3 6 9 12 4 8 12 16 5 10 15 20 1 2 3 2 4 6 3 6 9 4 8 12 5 10 15 6 12 18

Write a C++ program that would display the following output: 14. 0123456789 0123456789 0123456789 0123456789 0123456789 15. 1 * 2** 3*** 4**** 5***** 16. 1 1 1 1 1 2 2 2 2 3 3 3 4 4 5

13. Write a C++ program that would generate the output below: No. Square of a no. 1 1 2 4 3 9 4 16 5 25 (and so on) 14. Write a C++ program that would do an Exercises in Addition; first, second number and answer will be entered via a keyboard as shown in the sample output below. Sample Output: EXERCISES IN ADDITION Enter first number :9 Enter second number : 15 Enter your answer : 24 if answer is n or N it will quits the Program if answer is incorrect display the message Sorry! Your answer is incorrect