#8 Assume the declarations of Exercises 6 and 7. Write C++ statements that do th
ID: 3627829 • Letter: #
Question
#8 Assume the declarations of Exercises 6 and 7. Write C++ statements that do the following: Chapter 10 Exercises #8 pg 596 is the first one. And #12 is the second one down below
a. Store the following information in newEmployee:
name: Micky Doe
pID: 111111111
performanceRating: 2
dept: ACCT
salary: 34567.78
a. newEmployee.name = "John Smith";
b. In the array employees, intialize each performanceRating to 0.
c. Copy the information of the 20th component of the array employees into newEmployee.
d. Update the salary of the 50th employee in the array employees by adding 5735.87 to its previous value.
#12 pg 597
Suppose that you have the following definitions:
struct timeType struct tourType
{ {
int hr; string cityName;
double min; int distance;
int sec; timeType travelTime;
}; };
a. Declare the variable destination of type tourType.
b. Write C++ statements to store the following data in destination:
cityName-Chicago, distance- 550 miles, travelTime-9 hours
and 30 minutes.
c. Write the definition of a function to output the data stored in a variable of type tourType.
d. Write the definition of a value-returning function that inputs data into a variable of type tourType.
e. Write the definition of void function with a reference parameter of type tourType to input data in a variable of type tourType.
Explanation / Answer
a. Declare the variable destination of type tourType.
struct tourType destination;
b. Write C++ statements to store the following data in destination:
destination.cityname = Chicago;
destination.distance = 550;
destination.travelTime.hr = 9;
destination.travelTime.min = 30;
destination.travelTime.sec = 0;
c. Write the definition of a function to output the data stored in a variable of type tourType.
void output(struct tourType);
d. Write the definition of a value-returning function that inputs data into a variable of type tourType.
struct tourType input();
e. Write the definition of void function with a reference parameter of type tourType to input data in a variable of type tourType.
void referinput(struct *tourType);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.