Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Examen

Data Abstraction & Problem Solving with C++

Puntuación
-
Vendido
-
Páginas
333
Grado
A+
Subido en
18-02-2026
Escrito en
2025/2026

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

Institución
Data Abstraction & Problem Solving With C++
Grado
Data Abstraction & Problem Solving with C++

Vista previa del contenido

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

Escuela, estudio y materia

Institución
Data Abstraction & Problem Solving with C++
Grado
Data Abstraction & Problem Solving with C++

Información del documento

Subido en
18 de febrero de 2026
Número de páginas
333
Escrito en
2025/2026
Tipo
Examen
Contiene
Preguntas y respuestas

Temas

$18.89
Accede al documento completo:

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Conoce al vendedor
Seller avatar
Gradechaser

Conoce al vendedor

Seller avatar
Gradechaser Harvard University
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
-
Miembro desde
10 meses
Número de seguidores
1
Documentos
12
Última venta
-

0.0

0 reseñas

5
0
4
0
3
0
2
0
1
0

Documentos populares

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes