-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathExercise 16.2
65 lines (41 loc) · 1.98 KB
/
Exercise 16.2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
1. (Practice) Define arrays of 100 structures for each of the data types described in Exercise 1
of Section 16.1.
2. (Program) a. Using the data type
struct DaysInMonth
{
string name;
int days;
};
define an array of 12 structures of type DaysInMonth. Name the array convert[], and initialize
the array with the names of the 12 months in a year and the number of days in each month.
b. Include the array created in Exercise 2a in a program that displays the names of months and
number of days in each month.
3. (Program) Using the data type declared in Exercise 2a, write a C++ program that accepts a
month from a user in numerical form and displays the name of the month and the number of
days in the month. For example, in response to an input of 3, the program would display
March has 31 days.
4. (Program) a. Declare a single structure data type suitable for an employee structure of the
type shown in the following chart:
Number Name Rate Hours
3462 Jones 9.62 40
6793 Robbins 8.83 38
6985 Smith 8.22 45
7834 Swain 9.89 40
8867 Timmins 8.43 35
9002 Williams 9.75 42
b. Using the data type declared in Exercise 4a, write a C++ program that interactively accepts
the chart’s data in an array of six structures. After the data has been entered, the program
should create a payroll report listing each employee’s name, number, and gross pay. Include
the total gross pay of all employees at the end of the report.
5. (Program) a. Declare a single structure data type suitable for a car structure of the type
shown in the following chart:
Car Number Miles Driven Gallons Used
25 1450 62
36 3240 136
44 1792 76
52 2360 105
68 2114 67
b. Using the data type declared for Exercise 5a, write a C++ program that interactively accepts
the chart’s data in an array of five structures. After the data has been entered, the program
should create a report listing each car number and the car’s miles per gallon. At the end of
the report, include the average miles per gallon for the entire fleet of cars.