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

Lab 2 Struct

Uploaded by

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

Lab 2 Struct

Uploaded by

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

Object Oriented Programming with C++

Lab 2 Structures

Question:
A phone number, such as (212) 767-8900, can be thought of as having three parts: the area code
(212), the exchange (767), and the number (8900). Write a program that uses a structure to store
these three parts of a phone number separately. Call the structure phone. Create two structure
variables of type phone. Initialize one, and have the user input a number for the other one. Then
display both numbers. The interchange might look like this:

Enter your area code, exchange, and number: 415 555 1212
My number is (212) 767-8900
Your number is (415) 555-1212

Question:

Create a structure of type date that contains three members: the month, the day of the month, and
the year, all of type int. (Or use day-month-year order if you prefer.) Have the user enter a date in
the format 12/31/2001, store it in a variable of type struct date, then retrieve the values from the
variable and print them out in the same format.

Question:

- Create a structure called Employee that contains three data members: Name, salary, and
ID. The salary can be defined as a structure that contains five data members:
basic_salary, deductions, bonuses, tax, and net_salary.

net_salary = basic_salary + bonuses – deductions – tax.

- Your program should ask the user to enter the information of three employees.
- Your program should print the employees’ information as the following:

ID Name Basic Salary Bonuses Deductions Tax Net Salary


1 Khalid 1000 450 90 25 1335
2 Ahmed 500 220 75 5 640
3 Hamzeh 700 350 60 10 980

- Update the program to determine the tax


( tax = 0.07 ( 500 – 800 ) ) basic_salary
( tax = 0.10 ( 801 – 1200 ) ) basic_salary
( tax = 0.15 ( >=1201) ) basic_salary
(tax = 0.0 ( <=499))
- Update the program to search the employee info based on the Employee ID.
- Update the program to add a menu for choosing the operation (Insert Data, Print
Data, Search Data, Add a Record, Update Data, Quit)

You might also like