Problem Solving with C++ 8/E Savitch solutions manual and test bank and lab manual
I can get the Problem Solving with C++ 8/E Savitch solutions manual and test bank and lab manual, please send the email to me
- Problem Solving with C++ plus MyProgrammingLab with Pearson eText -- Access Card, 8/E
- Walter Savitch
ISBN-10: 0132576341 • ISBN-13: 9780132576345
©2012 • Online • Live
More info
1. Source Code Listings (ZIP) (0.3MB)
Zip file of all chapters
· Instructor Solutions Manual for Problem Solving with C++, 8/E
Savitch & Mock
ISBN-10: 0132317060 • ISBN-13: 9780132317061
©2012 • Online • Live
More info
1. Instructor Solutions Manual (ZIP) (0.6MB)
Zip file of all chapters
· Lab Manual for Problem Solving with C++, 8/E
Savitch
ISBN-10: 0132872595 • ISBN-13: 9780132872591
©2012 • Online • Live
More info
1. Lab Manual (ZIP) (0.8MB)
· PowerPoint Lecture Slides for Problem Solving with C++, 8/E
Savitch & Mock
ISBN-10: 0132317028 • ISBN-13: 9780132317023
©2012 • Online • Live
More info
1. PowerPoint Lecture Slides (ZIP) (29.1MB)
Zip file of all chapters
2. PowerPoint Figure Slides (ZIP) (57.4MB)
Zip file of all chapters
· Test Bank for Problem Solving with C++, 8/E
Savitch & Mock
ISBN-10: 0132317044 • ISBN-13: 9780132317047
©2012 • Online • Live
More info
1. Test Bank (Word files) (ZIP) (0.2MB)
Zip file of all chapters.
2. TestGen Testbank - Blackboard 9 TIF (ZIP) (0.5MB)
Click here for installation and file use instructions.
· Test Generator for Problem Solving with C++, 8/E
Savitch & Mock
ISBN-10: 0132317036 • ISBN-13: 9780132317030
©2012 • Online • Live
Chapter 2
C++
Basics
1.
Solutions to the Programming Projects:
1.
Metric - English units Conversion
A metric ton is 35,273.92 ounces. Write a C++ program
to read the weight of a box of cereal in ounces then output this weight in
metric tons, along with the number of boxes to yield a metric ton of cereal.
Design: To convert 14 ounces (of cereal) to metric
tons, we use the 'ratio of units' to tell us whether to divide or multiply:
The use of units will
simplify the determination of whether to divide or to multiply in making a
conversion. Notice that ounces/ounce becomes unit-less, so that we are left
with metric ton units. The number of ounces will be very, very much larger than
the number of metric tons. It is then reasonable to divide the number of ounces
by the number of ounces in a metric ton to get the number of metric tons.
Now let metricTonsPerBox be the weight of the cereal
box in metric tons. Let ouncesPerBox the be the weight of the cereal box in
ounces. Then in C++ the formula becomes:
const double ouncesPerMetric_ton
= 35272.92;
metricTonsPerBox = ouncesPerBox / ouncesPerMetricTon;
This is metric tons PER BOX, whence the number of
BOX(es) PER metric ton should be the reciprocal:
boxesPerMetricTon = 1 /
metricTonsPerBox;
Once this analysis is made, the code proceeds
quickly:
//Purpose: To convert cereal box weight from ounces to
// metric tons to compute number of boxes to make up a
// metric ton of cereal.
#include <iostream>
using namespace std;
const double ouncesPerMetricTon
= 35272.92;
int main()
{
double ouncesPerBox, metricTonsPerbox,
boxesPerMetricTon;
char ans = 'y';
while( 'y' == ans || 'Y' == ans )
{
cout << “enter the weight in ounces of your”
<< “favorite cereal:” <<endl;
cin >> ouncesPerBox;
metricTonsPerbox =
ouncesPerBox / ouncesPerMetricTon;
boxesPerMetricTon = 1 / metricTonsPerbox;
cout << "metric tons per box = "
<< metricTonsPerbox << endl;
cout << "boxes to yield a metric ton = "
<< boxesPerMetricTon << endl;
cout << " Y or y continues, any other character ”
<< “terminates." << endl;
cin >> ans;
}
return 0;
}
A sample run follows:
enter the weight in ounces of your favorite cereal:
14
metric tons per box = 0.000396905
boxes to yield a metric ton = 2519.49
Y or y continues, any other characters terminates.
y
enter the weight in ounces of your favorite cereal:
20
metric tons per box = 0.000567007
boxes to yield a metric ton = 1763.65
Y or y continues, any other characters terminates.
n
TRUE/FALSE
- A struct variable is declared differently from a predefined type such as an int.
ANSWER: FALSE
- Two different structure definitions may have the same member names.
ANSWER: TRUE.
- A structure can only be passed to a function as a call-by-value parameter
ANSWER: FALSE
- A function may return a structure.
ANSWER: TRUE
- Different class may not have member functions with the same name.
ANSWER: FALSE
- A class member function may be private.
ANSWER: TRUE
- Class data members are almost always public.
ANSWER: FALSE
- It is possible to have multiple private labels in a class definition.
ANSWER: TRUE
- The assignment operator may not be used with objects of a class.
ANSWER: FALSE
- All constructors for a class must be private.
ANSWER: FALSE
- A derived class is more specific than its parent, or base class.
ANSWER: TRUE
Short Answer
- The keyword ________ defines a structure type definition.
ANSWER: struct
- A structure definition ends with the closing brace and a _________.
ANSWER:
semicolon
- A structure variable is a collection of smaller values called ____________ values
ANSWER: member
- When a structure contains another structure variable as one of its members, it is known as a ___________________.
ANSWER:
hierarchical structure
- When several items (variables or variables and functions) are grouped together into a single package, that is known as ______________.
ANSWER: (data)
encapsulation
- The double colon (::) is known as the __________ operator.
ANSWER: scope
resolution operator
- Who can access private members in a class?
ANSWER: only
other members of the class
- A member function that allows the user of the class to find out the value of a private data type is called a ___________________.
ANSWER: accessor
function.
- A member function that allows the user of the class to change the value of a private data type is called a ____________________.
ANSWER: mutator
function.
- If you have a class with a member function called display(ostream& out), that will send the values in the class to the parameter stream, and you need to call that function from within another member function, how would you call it to print the data to the screen? ___________________________
ANSWER:
display(cout);
- What can a constructor return? _______________
ANSWER: nothing
- The name of a constructor is _____________
ANSWER: the name
of the class
- The constructor of a class that does not have any parameters is called a __________ constructor.
ANSWER: default
- In the following class constructor definition, the part of the header starting with a single colon is called the ________________.
BankAccount::BankAccount():
balance(0), interest(0.0)
ANSWER:
initialization section
- A class in which modifications to the implementation appear to be invisible to the user of the class is known as _________________.
ANSWER: an
Abstract Data Type (ADT)
- A member function that gets called automatically when an object of the class is declared is called a _______________.
ANSWER:
constructor
- If class A is derived from class B, then B is a _______ of A.
ANSWER: parent
Multiple Choice
- In a structure definition, the identifiers declared in the braces are called
- classes
- structs
- member names
- variables
ANSWER: C
- You specify an individual member of a struct by using
- the assignment operator
- an ampersand
- an underscore
- The dot operator
ANSWER: D
- To assign values to a structure variable, you use the
- equals operator
- assignment operator
- extraction operator
- less than operator
ANSWER: B
- What is wrong with the following structure definition?
struct MyStruct
{
int size;
float weight;
}
- Nothing
- Can not have mixed data types in a structure
- missing semicolon
- Braces are not needed.
ANSWER: C
- Given the following strucure definitions, what is the correct way to print the person's birth year?
struct DateType
{
int day;
int month;
int year;
}
struct PersonType
{
int age;
float weight;
DateType birthday;
}
PersonType person;
- cout << person.birthday.year;
- cout << year;
- cout << birthday.year;
- cout << peson.year;
ANSWER: A
- Given the following strucure definition, what is the correct way to initialize a variable called today?
struct DateType
{
int day;
int month;
int year;
}
- DateType today(1,1,2000);
- DateType today = (1,1,2000);
- DateType today = {1,1,2000);
- DateType today = {1,1,2000,0);
ANSWER: C
- When defining a class, the class should be composed of the kind of values a variable of the class can contain, and
- member functions for that class
- the keyword private
- other class definitions
- nothing else
ANSWER: A
- Which of the following is the correct function definition header for the getAge function which is a member of the Person class?
- int getAge();
- int getAge()
- int Person:getAge()
- int Person::getAge()
ANSWER: D
- Given the following class definition and the following member function header, which is the correct way to output the private data?
class Person
{
public:
void outputPerson(ostream& out);
private:
int age;
float weight;
int id;
};
void Person::outputPerson(ostream&
out)
{
//what goes here?
}
- out << person.age << person.weight << person.id;
- out << person;
- out << age << weight << id;
- outputPerson(person);
ANSWER: C
- Why do you want to usually make data members private in a class?
- so that no one can use the class.
- ensure data integrity
- provide data abstraction.
- provide information hiding.
- B and D
- B, C and D
ANSWER: F
- A member function of a class should be made private
- always
- only if it will never be used
- if it will only be used by other members of the class
- never, it is illegal to make a member function private.
ANSWER: C
- A member function that allow the user of the class to change the value in a data member is known as
- a mutator function
- a mutation
- a manipulator function
- an accessor function
ANSWER: A
- A Member function that allows the user of the class to see the value in a data member is known as
- a mutator function
- a mutation
- a manipulator function
- an accessor function
ANSWER: D
- If you design a class with private data members, and do not provide mutators and accessors, then
- The private data members can still be accessed from outside the class by using the & operator
- The data can not be changed or viewed by anyone.
- None of the above
- A and B
ANSWER: B
- A class member function that automatically initializes the data members of a class is called
- the init function
- an operator
- a constructor
- a cast
ANSWER: C
- If you have a class named myPersonClass, which of the following correctly declare a constructor in the class definition?
- myPersonClass::myPersonClass();
- myPersonClass();
- init();
- cast();
ANSWER: B
- given the following class definition, how could you use the constructor to assign values to an object of this class?
class CDAccount
{
public:
CDAccount();
CDAccount(float interest, float newBalance);
float getBalance();
float getRate();
void setRate(float interest);
void setBalance(float newBalance);
private:
float balance, rate;
};
and the
following object declaration
CDAccount
myAccount;
- myAccount = CDAccount(float myRate, float myBalance);
- myAccount = CDAccount {myRate, myBalance};
- myAccount = CDAccount[myRate, myBalance];
- myAccount = CDAccount(myRate, myBalance);
ANSWER: D
- Given the following class definition, what is missing?
class ItemClass
{
public:
ItemClass(int newSize, float newCost);
int getSize();
float getCost();
void setSize(int newSize);
void setCost(float newCost);
private:
int size;
float cost;
};
- nothing
- a default constructor
- accessor functions
- mutator functions
ANSWER: B
- Given the following class definition, how would you declare an object of the class, so that the object automatically called the default constructor?
class ItemClass
{
public:
ItemClass();
ItemClass(int newSize, float newCost);
int getSize();
float getCost();
void setSize(int newSize);
void setCost(float newCost);
private:
int size;
float cost;
};
- ItemClass() myItem;
- ItemClass myItem(1, 0.0);
- ItemClass myItem;
- ItemClass myItem();
- You can not do this
ANSWER: C
No comments:
Post a Comment