02 lab session 02.doc

2
CT025-3.5-2: Programming Concepts in C++ Page 1 of 2 Lab Session 2: Introduction to C++ Write simple programs in C++: 1. That will read in a ta x rate (as a per centag e) and the prices of fi ve items . The progr am is to calculate the total price, before tax, of the items, then the tax payable on those items. The tax payable is calculated by applying the tax rate percentage to the total  price. Print the total price and the tax payable as output. Note : do not use loop for this exercise. 2. Tha t will read the tota l number of regular hours worked, the tot al overtime hours worked and the hourly rate from user input and then calculate and print the weekly  pay owing to that employee. Weekly pay is calculated as payment for regular hours worked, plus payment for overtime hours worked. Payment for regular hours worked is calculated as (wage rate times regular hours worked); payment for overtime hours worked is calculated as (wage rate times overtime h ours worked times 1.5). 3. A progr am is re quired to read a customer ’s name, a p urchas e amount and a tax code. The tax code has been validated and will be one of the following: Code Tax S tatus 0 Tax Exempt (0%) 1 State Sales Tax Only (3%) 2 Federal and Sta te Sales Tax (5%) 3 Special Sales Tax (7%) The program must then compute the sales tax and the total amount due and print the customer’s name, purchase amount, sales tax and total amount due. The program should be able to perform the calculation for as many times as the user requires. 4. Develop an int era cti ve progra m tha t rea ds a low val ue, a high val ue, and an increment value, ensures that the low value is less than or equal to the high value, and computes and prints a table of square and cube values from low to high at increments of increment. Sample input-output :  Low value : 1  High value : 5  Increment : 1 Valu e Square Cube 1 1 1 2 4 8 3 9 27 4 16 64 5 25 125 Asia Pacific University College of Technology and Innovation 2011

Upload: kaushal-vaishnav

Post on 02-Apr-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 02 LAB SESSION 02.doc

7/27/2019 02 LAB SESSION 02.doc

http://slidepdf.com/reader/full/02-lab-session-02doc 1/2

CT025-3.5-2: Programming Concepts in C++ Page 1 of 2

Lab Session 2: Introduction to C++

Write simple programs in C++:

1. That will read in a tax rate (as a percentage) and the prices of five items. The program

is to calculate the total price, before tax, of the items, then the tax payable on thoseitems. The tax payable is calculated by applying the tax rate percentage to the total price. Print the total price and the tax payable as output. Note : do not use loop for this exercise.

2. That will read the total number of regular hours worked, the total overtime hoursworked and the hourly rate from user input and then calculate and print the weekly pay owing to that employee. Weekly pay is calculated as payment for regular hoursworked, plus payment for overtime hours worked. Payment for regular hours workedis calculated as (wage rate times regular hours worked); payment for overtime hoursworked is calculated as (wage rate times overtime hours worked times 1.5).

3. A program is required to read a customer’s name, a purchase amount and a tax code.

The tax code has been validated and will be one of the following:

Code Tax Status

0 Tax Exempt (0%)

1 State Sales Tax Only (3%)

2 Federal and State Sales Tax (5%)

3 Special Sales Tax (7%)

The program must then compute the sales tax and the total amount due and print thecustomer’s name, purchase amount, sales tax and total amount due. The programshould be able to perform the calculation for as many times as the user requires.

4. Develop an interactive program that reads a low value, a high value, and anincrement value, ensures that the low value is less than or equal to the high value,and computes and prints a table of  square and cube values from low to high atincrements of increment.

Sample input-output :

 Low value : 1

 High value : 5

 Increment  : 1

Valu

e

Square Cube

1 1 12 4 83 9 274 16 645 25 125

Asia Pacific University College of Technology and Innovation 2011

Page 2: 02 LAB SESSION 02.doc

7/27/2019 02 LAB SESSION 02.doc

http://slidepdf.com/reader/full/02-lab-session-02doc 2/2

CT025-3.5-2: Programming Concepts in C++ Page 1 of 2

5. A weather station receives 15 temperatures in Fahrenheit. Develop an applicationwhich will accept each Fahrenheit temperature and convert it to Celsius and displaythe converted temperature. After 15 temperatures have been processed, the message“All temperatures processed” is displayed on the screen. The formula for convertingFahrenheit to Celsius is as follows:

FtoC = (fahrenheit – 32) * 5/9

 Sample input output:

Enter temperature 1 in Fahrenheit : 100

100 Fahrenheit = 37.78 Celsius

Enter temperature 2 in Fahrenheit : 10

10 Fahrenheit = -12.22 Celsius.

..Enter temperature 15 in Fahrenheit : 80

80 Fahrenheit = 26.67 Celsius

6. The tax payable on taxable incomes for employees in a certain country is set out inthe following table:

Taxable Income Tax Payable

From $1.00 - $4461.99 Nil

From $4462.00 - $17893.99 Nil plus 30 cents for each $ in excess of $4462.00

From $17894.00 - $29499.99 $4119.00 plus 35 cents for each $ in excess of $17894.00From $29500.00 - $45787.99 $8656.00 plus 46 cents for each $ in excess of $29500.00$45788.00 and over $11179.00 plus 60 cents for each $ in excess of $45788.00

Develop an application that will read as input the taxable income amount andcalculate and display the tax payable on that amount.

 Sample input-output:

Income: $5000

The tax payable for your income of $5000.00 is $161.40

Income: $20000The tax payable for your income of $2000.00 is $4856.10

Income: $0.25

Asia Pacific University College of Technology and Innovation 2011