What changes would need be made to Listing 7.15 so that the functions fill() and show() use
Question:
What changes would need be made to Listing 7.15 so that the functions fill() and show() use reference parameters?
Here’s a sample run:
Enter Spring expenses: 212
Enter Summer expenses: 256
Enter Fall expenses: 208
Enter Winter expenses: 244
EXPENSES
Spring: $212
Summer: $256
Fall: $208
Winter: $244
Total: $920
Transcribed Image Text:
Listing 7.15 arrobj.cpp
//arrobj.cpp - functions with array objects (C++11)
#include
Listing 7.15 arrobj.cpp
//arrobj.cpp - functions with array objects (C++11)
#include
#include
#include
// constant data.
const int seasons = 4;
const std::array Snames =
{"Spring", "Summer", "Fall", "Winter");
// function to modify array object
void fill (std:: array pa);
// function that uses array object without modifying it
void show (std:: array da);
int main()
{
}
void fill (std:: array pa).
{
}
std:: array expenses;
fill(&expenses);
show (expenses);
return 0;
}
using namespace std;
for (int i = 0; i < Seasons; i++)
{
}
void show (std:: array da)
{
cout << "Enter" << Snames [1] << " expenses: ";
cin>> (*pa) [1];
using namespace std;
for (int i = 0; i < Seasons; i++).
{
}
cout << "Enter" << Snames [1] << expenses: ";
cin >> (pa) [i];
void show (std:: array da)
{
using namespace std;
double total = 0.0;
cout << "\nEXPENSES\n";
for (int i = 0; i < Seasons; i++)
{
cout << Snames [1] << ": $" << da[i] << endl;
total da [i];
}
cout << "Total Expenses: $" << total << endl;
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 64% (14 reviews)
ANSWER The changes that would need to be made to Listing ...View the full answer
Answered By
Dennis Nyangau
I have been tutoring for several years now, and I absolutely love it! I love being able to help students one-on-one and see them succeed. It is so gratifying to see a student understand a concept that they were struggling with before. I also enjoy getting to know my students and helping them to reach their full potential.
0.00
0 Reviews
10+ Question Solved
Related Book For
Question Posted:
Students also viewed these Computer science questions
-
What changes would be needed for Windows 2000 to run a process that uses a 64-bit address space?
-
Show how quick sort can be made to run in O (n lg n) time in the worst case.
-
A helical compression spring is to be made of oil-tempered wire of 4-mm diameter with a spring index of C = 10. The spring is to operate inside a hole, so buckling is not a problem and the ends can...
-
Hardie Lord, Helen Murvis's boss, is not convinced that Helen used the correct decision technique. Hardie believes that Helen should use a coefficient of realism of 0.75 in determining the best...
-
Compare and contrast the roles that a firm's treasurer and controller have in the operation of the firm.
-
Argon gas enters a turbine at 7 MPa and 600 K with a velocity of 100 m/s and leaves at 1 MPa and 280 K with a velocity of 150 m/s at a rate of 5 kg/s. Heat is being lost to the surroundings at...
-
Factory Express Ltd operates two departments Truck and Trailer. During the year ended 30 June 2025, the store had the following financial results. Required Prepare departmental statements of...
-
Barnum Distributors wants a projection of cash receipts and cash payments for the month of November. On November 28, a note will be payable in the amount of $98,500, including interest. The cash...
-
explain the significance of partition coefficients in determining the distribution of solutes between immiscible phases, and how does this concept guide the choice of solvents in extraction processes...
-
With the intent of countering pollution and global warming, the government has created the Ontario Environmental Watchdog Commission. The Commission's role is to track corporate polluters in the...
-
The following is a program skeleton: #include using namespace std; #include // for strlen(), strcpy() struct stringy { char * str; // points to a string int ct; // length of string (not counting...
-
The following is a structure template: struct box { char maker[40]; float height; float width; float length; float volume; }; a. Write a function that has a reference to a box structure as its formal...
-
What was the net increase or decrease in cash flow from having purchased the foreign currency option to hedge this exposure to foreign exchange risk? a. $0. b. A $1,000 increase in cash flow. c. A...
-
The following table contains financial information for Trumpeter Inc. before closing entries: Cash Supplies Prepaid Rent $13,400 6,000 3,600 Salaries Expense 4,800 Equipment 66,000 Service Revenue...
-
Expanding Working Hours Alma Cafe is considering expanding their opening hours on Saturdays by 3 hours. The caf is usually open from 8am to 6pm, but there's potential for additional revenue if we...
-
2. Given the following method static void nPrint(String message, int n) { while (n > 0) { System.out.print(message); n-- } } What is k after invoking nPrint("A message", k)? int k = 2; nPrint("A...
-
Nora invested $8,000 in a qualified tuition program for the benefit of her son. Four years later her son, Michael withdrew $10,000, the entire balance in the program, to pay his college tuition. How...
-
1. From a line manager: I attach a collage of job advertisements that prove my contention that we are seriously underpaying my key staff. How do you reply? 2. From the HR director to the head of...
-
Construct a coloring of the graph shown using this algorithm. a b
-
If the jobs displayed in Table 18.24 are processed using the earliestdue-date rule, what would be the lateness of job C? TABLE 18.24 Processing Times and Due Dates for Five Jobs Job C D E...
-
Write a code segment to ask a user to enter a number between 1 and 12 , and print the name of the month corresponding to the number. Use a selection structure.
-
Repeat the previous exercise using a selection structure instead of a case structure. Data From previous exercise Write a code segment to ask a user to enter a number between 1 and 4 , and print the...
-
Write a code segment to ask a user to enter a number between 1 and 4 , and print the name of the class (First-Year, Sophomore, Junior, and Senior) corresponding to the number. Use a case structure.
-
Find the first derivative of the following equation: a. b. y=e3x y=e(x+1) d. y=125x+16-2x y=ln x y=ln (3x+x1) y=In (x+1)
-
The Cutting Department of Lasso Company has the following production and cost data for August. Production Costs 1. Started and completed 9,600 units. Beginning work in process $0 2. Started 2,300...
-
There is sufficient evidence to support the conclusion that a robust relationship exists between drugs and crime. Explain and discuss the studies that support this conclusion. Further explain and...
Study smarter with the SolutionInn App