You are on page 1of 4

# CSC103 # 2 2012 2013

University of Bahrain College of Information Technology Department of Computer Science CSC 103

Tutorial#4
1. The 1988 United States Federal Tax Schedule was the simplest in recent times. It had four categories, and each category has two rates. Here is a summary; dollar amounts are taxable income. Category Single Head of Household Married, Joint Married, Separate Tax 15% of first \$17,850 plus 28% of excess 15% of first \$23,900 plus 28% of excess 15% of first \$29,750 plus 28% of excess 15% of first \$14,875 plus 28% of excess

For example, a single wage earner with a taxable income of \$20,000 dollars owes 0.15 x \$17,850 + 0.28 x (\$20,000 - \$17,850). Write a program that lets the user enter the tax category and the taxable income then calculates and prints the tax. Sample input/output Enter the category : S Enter taxable income : 20000 Tax = 3279. 2. Write C++ program to calculate and output the net price of a pizza based on two user inputs: size (S for small, M for medium ,or L for large) and number of toppings. The net price of pizza is the sum of the follows: Base price of the pizza is \$8.50 for small, \$10.50 for medium, and \$12.50 for large. The first topping is free; the second and subsequent topping is an addition \$0.50 for each. Sales tax is an additional 7% of the total price. 3. Write a C++ program that accepts the salary of the employee, then deducts the income tax from the salary on the following basis :

30% income tax if the salary is above or equal \$15000. 20% income tax if the salary is between \$7000 and \$15000. 10% income tax if the salary is below or equal \$7000. Your program then should output the salary, income tax and the net salary.

## CSC103 # 2 2012 2013

4. Write a C++ program that asks the user to enter ID number and GPA of 50 students. The program should output into a new file RESULT.DAT the ID, the GPA with 2 decimal places and the result (either PASS or FAIL) separated by space, each student record in a new line. The result is PASS if GPA is greater than or equal to 2.0, FAIL otherwise. i.e if the first two input is 20071122 1.8 and 20072233 3.7 then the first two lines in the file should be 20071122 1.8 FAIL 20072233 3.7 PASS

5. ABC department store offers a prize if the persons purchases exceed 150 dinars. The prize will be given based on age range. Draw a flowchart that read a purchase and age. The program should display the corresponding prize based on age range according to the table below. Age Between 14 and 25 Between 26 and 40 Between 41 and 55 55 and above Prize received Cell phone Voucher with 40 BD Coffee machine Microwave machine

6. Write a C++ program that calculates and displays the ideal weight based on the users age and height. The formula is as follows. Note that the weight given by the formula is in kilograms. AGE GROUP persons up to and including age 18 persons between age 19 years and 55 inclusive persons between 56 years and 75 inclusive persons over the age of 76 years IDEAL WEIGHT FORMULA (height - 36) / 2 ((height - 36) / 2) + ((age - 18) / 7) ((height - 36) / 2) + ((37 / 7) - ((age - 55) / 4)) same as for those of 18 years or younger

Sample Input/Output
Enter your height and age: 175 35 Ideal weight for that person = 71.9286

## CSC103 # 2 2012 2013

7. What is the output of the following code? int a, b; a = 5; b = 3; switch ( a + b ) { case 1: case 2: cout<<"Option 1";break; case 3: cout<<"Option 2";break; default: cout<<"Option 3\n"; } cout<<"Option 2"; 8. What is the output of the following code? int x, y; x = 3; y = x + 5; if ( ( x == y ) || ( y < x ) ) { cout<<"Expression is true\n"; } else { cout<< "Expression is false\n" ;}

9. Suppose that the input is 0. What is output of the following code? cin >> angle; if (angle > 5) angle = angle + 5; else if (angle > 2) angle = angle + 10; cout << angle; 10. What is the output of the following C++ code? int y = 5, x = 55; switch (x % 7) { case 0: case 1: y++; case 2: case 3: y = y + 2; break; case 5: case 6: y = y 3; } cout << y << endl;

## CSC103 # 2 2012 2013

11. What is the output of the following code fragment if the input value is 20? cin >> someInt; if (someInt > 30) cout << "Mo "; cout << "Larry "; cout << "Curly";

12. What would the value of Enter be after execution of this code if the value input for Enter was 4? int Enter ; cin >> Enter; switch (Enter) { case 1: Enter = -4; case 2: Enter = -6; case 4: break; case 6: Enter = -8; break; default: Enter = -1; }