Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
Tentamen (uitwerkingen)

Data Abstraction & Problem Solving with C++

Beoordeling
-
Verkocht
-
Pagina's
333
Cijfer
A+
Geüpload op
18-02-2026
Geschreven in
2025/2026

Data Abstraction & Problem Solving with C++.With Solutions.A+ Assured!!!!

Instelling
Data Abstraction & Problem Solving With C++
Vak
Data Abstraction & Problem Solving with C++

Voorbeeld van de inhoud

Solutions to Selected Exercises

(Version 7.0)



Data Abstraction & Problem Solving with C++

Seventh Edition




Frank M. Carrano
University of Rhode Island
Timothy M. Henry
New England Institute of Technology

, 2


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




Chapter 1 Data Abstraction: The Walls
1
const CENTS_PER_DOLLAR = 100;

/** Computes the change remaining from purchasing an item costing
dollarCost dollars and centsCost cents with d dollars and c cents.
Precondition: dollarCost, centsCost, d and c are all nonnegative
integers and centsCost and c are both less than CENTS_PER_DOLLAR.
Postcondition: d and c contain the computed remainder values in
dollars and cents respectively. If input value d < dollarCost, the
proper negative values for the amount owed in d dollars and/or c
cents is returned. */
void computeChange(int dollarCost, int centsCost, int& d, int& c);

2a
const MONTHS_PER_YEAR = 12;
const DAYS_PER_MONTH[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

/** Increments the input Date values (month, day, year) by one day.
Precondition: 1 <= month <= MONTHS_PER_YEAR,
1 <= day <= DAYS_PER_MONTH[month - 1], except
when month == 2, day == 29 and isLeapYear(year) is true.
Postcondition: The valid numeric values for the succeeding month, day,
and year are returned. */
void incrementDate(int& month, int& day, int& year);

/** Determines if the input year is a leap year.
Precondition: year > 0.
Postcondition: Returns true if year is a leap year; false otherwise. */
bool isLeapYear(int year);

3a
changeAppointmentPurpose(apptDate: Date, apptTime: Time, purpose: string): boolean
{
if (isAppointment(apptDate, apptTime))
cancelAppointment(apptDate, apptTime)

return makeAppointment(apptDate, apptTime, purpose)
}




© 2017 Pearson Education, Inc., Hoboken, New Jersey 07030

, 3



3b
displayAllAppointments(apptDate: Date): void
{
time = START_OF_DAY
while (time < END_OF_DAY)
if (isAppointment(apptDate, time))
displayAppointment(apptDate, time)
time = time + HALF_HOUR
}
This implementation requires the definition of a new operation
displayAppointment()
as well as definitions for the constants START_OF_DAY, END_OF_DAY and HALF_HOUR.


4
// Assume that storeBag is defined and contains your purchased items
Bag<std::string> fragileBag;
while (storeBag.contains("eggs"))
{
storeBag.remove("eggs");
fragileBag.add("eggs");
} // end while

while (storeBag.contains("bread"))
{
storeBag.remove("bread");
fragileBag.add("bread");
} // end while

// Transfer remaining items from storeBag to groceryBag;
Bag<std::string> groceryBag;
v = storeBag.toVector();
for (int i = 0; i < v.size(); i++)
groceryBag.add(v.at(i));




© 2017 Pearson Education, Inc., Hoboken, New Jersey 07030

, 4



5
/** Removes and counts all occurrences, if any, of a given string
from a given bag of strings.
@param bag A given bag of strings.
@param givenString A string.
@return The number of occurrences of givenString that occurred
and were removed from the given bag. */
int removeAndCount(ArrayBag<std::string>& bag, std::string givenString)
{
int counter = 0;
while (bag.contains(givenString))
{
counter++;
bag.remove(givenString);
} // end while
return counter;
} // end removeAndCount



6
/** Creates a new bag that combines the contents of this bag and a
second bag without affecting the contents of the original two bags.
@param anotherBag The second bag.
@return A bag that is the union of the two bags. */
public BagInterface<ItemType> union(BagInterface<ItemType> anotherBag);



7
/** Creates a new bag that contains those objects that occur in both this
bag and a second bag without affecting the contents of the original two bags.
@param anotherBag The given bag.
@return A bag that is the intersection of the two bags. */
public BagInterface<ItemType> intersection(BagInterface<ItemType> anotherBag);



8
/** Creates a new bag of objects that would be left in this bag after removing
those objects that also occur in a second bag without the contents of the
original two bags.
@param anotherBag The given bag.
@return A bag that is the difference of the two bags. */
public BagInterface<T> difference(BagInterface<T> anotherBag);




© 2017 Pearson Education, Inc., Hoboken, New Jersey 07030

Geschreven voor

Instelling
Data Abstraction & Problem Solving with C++
Vak
Data Abstraction & Problem Solving with C++

Documentinformatie

Geüpload op
18 februari 2026
Aantal pagina's
333
Geschreven in
2025/2026
Type
Tentamen (uitwerkingen)
Bevat
Vragen en antwoorden

Onderwerpen

€16,97
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Maak kennis met de verkoper
Seller avatar
Gradechaser

Maak kennis met de verkoper

Seller avatar
Gradechaser Harvard University
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
-
Lid sinds
10 maanden
Aantal volgers
1
Documenten
12
Laatst verkocht
-

0,0

0 beoordelingen

5
0
4
0
3
0
2
0
1
0

Populaire documenten

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Veelgestelde vragen