Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 4 out of 349 pages
Exam (elaborations)

SOLUTION MANUAL FOR Data Abstraction & Problem Solving with C++: Walls and Mirrorsby Frank Carrano , Timothy Henry ISBN:978-0134463971 NEW COMPLETE GUIDE WITH RATIONALES 100% VERIFIED A+ GRADE ASSURED!!!!!NEW LATEST UPDATE!!!

Document preview thumbnail
Preview 4 out of 349 pages

SOLUTION MANUAL FOR Data Abstraction & Problem Solving with C++: Walls and Mirrorsby Frank Carrano , Timothy Henry ISBN:978-0134463971 NEW COMPLETE GUIDE WITH RATIONALES 100% VERIFIED A+ GRADE ASSURED!!!!!NEW LATEST UPDATE!!!

Content preview

Solutions to Selected Exercises
a w a w a w




(Version 7.0) aw




Data Abstraction & Problem Solving with C++
aw aw aw aw aw aw




Seventh Edition a w




Frank M. Carrano aw aw




University of Rhode Island
aw aw aw




Timothy M. Henry aw aw




New England Institute of Technology
aw aw aw aw

, 2


Solution Manual & Test Bank for Data Abstraction & Problem Solving with C++: Walls and Mirrors, 7th Edition by Frank M. Carrano
aw aw aw aw aw aw aw aw aw aw aw aw aw aw aw aw aw aw aw aw aw




Chapter 1 Data Abstraction: The Walls aw aw aw aw aw




1
const CENTS_PER_DOLLAR = 100;
aw aw aw




/** Computes the change remaining from purchasing an item costing dollarC
aw aw aw aw aw aw aw aw aw aw


ost dollars and centsCost cents with d dollars and c cents. Preconditi
aw aw aw aw aw aw aw aw aw aw aw



on: dollarCost, centsCost, d and c are all nonnegative integers and ce
aw aw aw aw aw aw aw aw aw aw aw



ntsCost and c are both less than CENTS_PER_DOLLAR. Postcondition: d a
aw aw aw aw aw aw aw aw aw aw



nd c contain the computed remainder values in dollars and cents respec
aw aw aw aw aw aw aw aw aw aw aw


tively. If input value d < dollarCost, the proper negative values for
aw aw aw aw aw aw aw aw aw aw aw aw


the amount owed in d dollars and/or c cents is returned. */
aw aw aw aw aw aw aw aw aw aw aw



void computeChange(int dollarCost, int centsCost, int& d, int& c);
aw aw aw aw aw aw aw aw




2a
const MONTHS_PER_YEAR = 12;
aw aw aw



const DAYS_PER_MONTH[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
aw aw aw aw aw aw aw aw aw aw aw aw aw aw




/** Increments the input Date values (month, day, year) by one day.
aw aw aw aw aw aw aw aw aw aw aw



Precondition: 1 <= month <= MONTHS_PER_YEAR, aw aw aw aw aw



1 <= day <= DAYS_PER_MONTH[month - 1], except aw aw aw aw aw aw aw



when month == 2, day == 29 and isLeapYear(year) is true. Postcondit aw aw aw aw aw aw aw aw aw aw aw



ion: The valid numeric values for the succeeding month, day,
aw aw aw aw aw aw aw aw aw



and year are returned. */ aw aw aw aw


void incrementDate(int& month, int& day, int& year);
aw aw aw aw aw aw




/** Determines if the input year is a leap year.
aw aw aw aw aw aw aw aw aw



Precondition: year > 0. aw aw aw



Postcondition: Returns true if year is a leap year; false otherwise. */ aw aw aw aw aw aw aw aw aw aw aw



bool isLeapYear(int year);
aw aw




3a
changeAppointmentPurpose(apptDate: Date, apptTime: Time, purpose: string): boolean aw aw aw aw aw aw



{
if (isAppointment(apptDate, apptTime)) cancelAppointment(apptDate
aw aw aw


, apptTime) aw




return makeAppointment(apptDate, apptTime, purpose)
aw aw aw


}




© 2017 Pearson Education, Inc., Hoboken, New Jersey 070
aw aw aw aw aw aw aw aw


30

, 3



3b
displayAllAppointments(apptDate: Date): void aw aw



{
time = START_OF_DAY aw aw



while (time < END_OF_DAY) aw aw aw



if (isAppointment(apptDate, time)) displa
aw aw aw


yAppointment(apptDate, time) aw



time = time + HALF_HOURaw aw aw aw



}
This implementation requires the definition of a new operation
aw aw aw aw aw aw aw aw




displayAppointment()
as well as definitions for the constants START_OF_DAY, END_OF_DAY and HALF_HOUR.
aw a w aw aw aw aw aw aw aw a w




4
// Assume that storeBag is defined and contains your purchased items Bag<std::string>
aw aw aw aw aw aw aw aw aw aw aw aw


fragileBag;
while (storeBag.contains("eggs"))
aw


{
storeBag.remove("eggs"); fragileBag.add("eggs" aw



);
} // end while
a w aw aw




while (storeBag.contains("bread"))
aw



{
storeBag.remove("bread"); fragileBag.add("brea aw



d");
} // end while
a w aw aw




// Transfer remaining items from storeBag to groceryBag; Bag<std::st
aw aw aw aw aw aw aw aw


ring> groceryBag; aw



v = storeBag.toVector();
aw aw



for (int i = 0; i < v.size(); i++) groceryBag.add
aw aw aw aw aw aw aw aw aw


(v.at(i));




© 2017 Pearson Education, Inc., Hoboken, New Jersey 070
aw aw aw aw aw aw aw aw


30

, 4



5
/** Removes and counts all occurrences, if any, of a given string from
aw aw aw aw aw aw aw aw aw aw aw aw aw



a given bag of strings.
aw aw aw aw



@param bag A given bag of strings. @pa
aw aw aw aw aw aw aw



ram givenString A string.
aw aw aw



@return The number of occurrences of givenString that occurred and
aw aw aw aw aw aw aw aw aw aw



were removed from the given bag. */
aw aw aw aw aw aw



int removeAndCount(ArrayBag<std::string>& bag, std::string givenString)
aw aw aw aw


{
int counter = 0; aw aw aw



while (bag.contains(givenString))
aw


{
counter++; bag.remove(givenString aw



);
} // end while
a w aw aw



return counter; aw



} // end removeAndCount
a w aw aw




6
/** Creates a new bag that combines the contents of this bag and a second ba
aw aw aw aw aw aw aw aw aw aw aw aw aw aw aw



g without affecting the contents of the original two bags.
aw aw aw aw aw aw aw aw aw



@param anotherBag The second bag.
aw a w aw aw



@return A bag that is the union of the two bags. */
a w aw aw aw aw aw aw aw aw aw aw



public BagInterface<ItemType> union(BagInterface<ItemType> anotherBag);
aw aw aw




7
/** Creates a new bag that contains those objects that occur in both this
aw aw aw aw aw aw aw aw aw aw aw aw aw



bag and a second bag without affecting the contents of the original two bags. @par
aw aw aw aw aw aw aw aw aw aw aw aw aw aw


am anotherBag The given bag.
aw aw aw aw



@return A bag that is the intersection of the two bags. */
a w aw aw aw aw aw aw aw aw aw aw


public BagInterface<ItemType> intersection(BagInterface<ItemType> anotherBag);
aw aw aw




8
/** Creates a new bag of objects that would be left in this bag after removing those ob
aw aw aw aw aw aw aw aw aw aw aw aw aw aw aw aw aw



jects that also occur in a second bag without the contents of the original two bag
aw aw aw aw aw aw aw aw aw aw aw aw aw aw aw


s.
@param anotherBag The given bag.
aw a w aw aw



@return A bag that is the difference of the two bags. */
a w aw aw aw aw aw aw aw aw aw aw



public BagInterface<T> difference(BagInterface<T> anotherBag);
aw aw aw




© 2017 Pearson Education, Inc., Hoboken, New Jersey 070
aw aw aw aw aw aw aw aw


30

Document information

Uploaded on
August 27, 2026
Number of pages
349
Written in
2026/2027
Type
Exam (elaborations)
Contains
Questions & answers
$18.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Brightspark
3.7
(3)
Sold
17
Followers
0
Items
470
Last sold
1 month ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions