-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathExercise 16.1
64 lines (49 loc) · 2.63 KB
/
Exercise 16.1
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
63
64
1. (Practice) Declare a structure data type named Stemp for each of the following records:
a. A student record consisting of a student identification number, number of credits completed,
and cumulative grade point average
b. A student record consisting of a student’s name, birth date, number of credits completed,
and cumulative grade point average
c. A mailing list consisting of last name, first name, street address, city, state, and zip code
d. A stock record consisting of the stock’s name, the stock’s price, and the date of purchase
e. An inventory record consisting of an integer part number, a part description, the number of
parts in inventory, and an integer reorder number
2. (Practice) For the data types declared in Exercise 1, define a suitable structure variable name,
and initialize each structure with the following data:
a. Identification Number: 4672
Number of Credits Completed: 68
Grade Point Average: 3.01
b. Name: Rhona Karp
Birth Date: 8/4/1980
Number of Credits Completed: 96
Grade Point Average: 3.89
c. Name: Kay Kingsley
Street Address: 614 Freeman Street
City: Indianapolis
State: IN
Zip Code: 07030
d. Stock Name: IBM
Stock Price: 134.5
Date Purchased: 10/1/2010
e. Part Number: 16879
Part Description: Battery
Number in Stock: 10
Reorder Number: 3
3. (Program) a. Write a C++ program that prompts a user to enter the current month, day, and
year. Store the entered data in a suitably defined record and display the date in an appropriate
manner.
b. Modify the program written in Exercise 3a to use a record that accepts the current time in
hours, minutes, and seconds.
4. (Program) Write a C++ program that uses a structure for storing a stock name, its estimated
earnings per share, and its estimated price-to-earnings ratio. Have the program prompt the user
to enter these items for five different stocks, each time using the same structure to store the
entered data. When data has been entered for a particular stock, have the program compute
and display the anticipated stock price based on the entered earnings and price-per-earnings
values. For example, if a user enters the data XYZ 1.56 12, the anticipated price for a share
of XYZ stock is (1.56) × (12) = $18.72.
5. (Program) Write a C++ program that accepts a user-entered time in hours and minutes. Have
the program calculate and display the time 1 minute later.
6. (Program) a. Write a C++ program that accepts a user-entered date. Have the program calculate
and display the date of the next day. For the purposes of this exercise, assume all months
consist of 30 days.
b. Modify the program written in Exercise 6a to account for the actual number of days in
each month.