Search This Blog(textbook name or author as the keywords)You can cantact me by the Contact Form

9/13/13

Problem Solving with C++ 8/E Savitch solutions manual and test bank and lab manual


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
  Book cover

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
  1. A struct variable is declared differently from a predefined type such as an int.
ANSWER: FALSE
  1. Two different structure definitions may have the same member names.
ANSWER: TRUE.
  1. A structure can only be passed to a function as a call-by-value parameter
ANSWER: FALSE
  1. A function may return a structure.
ANSWER: TRUE
  1. Different class may not have member functions with the same name.
ANSWER: FALSE
  1. A class member function may be private.
ANSWER: TRUE
  1. Class data members are almost always public.
ANSWER: FALSE
  1. It is possible to have multiple private labels in a class definition.
ANSWER: TRUE
  1. The assignment operator may not be used with objects of a class.
ANSWER: FALSE
  1. All constructors for a class must be private.
ANSWER: FALSE
  1. A derived class is more specific than its parent, or base class.
ANSWER: TRUE

Short Answer
  1. The keyword ________ defines a structure type definition.
ANSWER: struct
  1. A structure definition ends with the closing brace and a _________.
ANSWER: semicolon
  1. A structure variable is a collection of smaller values called ____________ values
ANSWER: member
  1. When a structure contains another structure variable as one of its members, it is known as a ___________________.
ANSWER: hierarchical structure
  1. When several items (variables or variables and functions) are grouped together into a single package, that is known as ______________.
ANSWER: (data) encapsulation
  1. The double colon (::) is known as the __________ operator.
ANSWER: scope resolution operator
  1. Who can access private members in a class?
ANSWER: only other members of the class
  1. 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.
  1. 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.
  1. 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);
  1. What can a constructor return? _______________
ANSWER: nothing
  1. The name of a constructor is _____________
ANSWER: the name of the class
  1. The constructor of a class that does not have any parameters is called a __________ constructor.
ANSWER: default
  1. 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
  1. 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)
  1. A member function that gets called automatically when an object of the class is declared is called a _______________.
ANSWER: constructor
  1. If class A is derived from class B, then B is a _______ of A.
ANSWER: parent

Multiple Choice
  1. In  a structure definition, the identifiers declared in the braces are called
    1. classes
    2. structs
    3. member names
    4. variables
ANSWER: C
  1. You specify an individual member of a struct by using
    1. the assignment operator
    2. an ampersand
    3. an underscore
    4. The dot operator
ANSWER: D
  1. To assign values to a structure variable, you use the
    1. equals operator
    2. assignment operator
    3. extraction operator
    4. less than operator
ANSWER: B
  1. What is wrong with the following structure definition?
struct MyStruct
{
  int size;
  float weight;
}
    1. Nothing
    2. Can not have mixed data types in a structure
    3. missing semicolon
    4. Braces are not needed.
ANSWER: C
  1. 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;
    1. cout << person.birthday.year;
    2. cout << year;
    3. cout << birthday.year;
    4. cout << peson.year;
ANSWER: A
  1. Given the following strucure definition, what is the correct way to initialize a variable called today?
struct DateType
{
  int day;
  int month;
  int year;
}

    1. DateType today(1,1,2000);
    2. DateType today = (1,1,2000);
    3. DateType today = {1,1,2000);
    4. DateType today = {1,1,2000,0);
ANSWER: C
  1. When defining a class, the class should be composed of the kind of values a variable of the class can contain, and
    1. member functions for that class
    2. the keyword private
    3. other class definitions
    4. nothing else
ANSWER: A
  1. Which of the following is the correct function definition header for the getAge function which is a member of the Person class?
    1. int getAge();
    2. int getAge()
    3. int Person:getAge()
    4. int Person::getAge()
ANSWER: D
  1. 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?
}
    1. out << person.age << person.weight << person.id;
    2. out << person;
    3. out << age << weight << id;
    4. outputPerson(person);
ANSWER: C
  1. Why do you want to usually make data members private in a class?
    1. so that no one can use the class.
    2. ensure data integrity
    3. provide data abstraction.
    4. provide information hiding.
    5. B and D
    6. B, C and D
ANSWER: F
  1. A member function of a class should be made private
    1. always
    2. only if it will never be used
    3. if it will only be used by other members of the class
    4. never, it is illegal to make a member function private.
ANSWER: C
  1. A member function that allow the user of the class to change the value in a data member is known as
    1. a mutator function
    2. a mutation
    3. a manipulator function
    4. an accessor function
ANSWER: A
  1. A Member function that allows the user of the class to see the value in a data member is known as
    1. a mutator function
    2. a mutation
    3. a manipulator function
    4. an accessor function
ANSWER: D
  1. If you design a class with private data members, and do not provide mutators and accessors, then
    1. The private data members can still be accessed from outside the class by using the & operator
    2. The data can not be changed or viewed by anyone.
    3. None of the above
    4. A and B
ANSWER: B
  1. A class member function that automatically initializes the data members of a class is called
    1. the init function
    2. an operator
    3. a constructor
    4. a cast
ANSWER: C
  1. If you have a class named myPersonClass, which of the following correctly declare a constructor in the class definition?
    1. myPersonClass::myPersonClass();
    2. myPersonClass();
    3. init();
    4. cast();
ANSWER: B
  1. 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;
    1. myAccount = CDAccount(float myRate, float myBalance);
    2. myAccount = CDAccount {myRate, myBalance};
    3. myAccount = CDAccount[myRate, myBalance];
    4. myAccount = CDAccount(myRate, myBalance);
ANSWER: D
  1. 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;
};
    1. nothing
    2. a default constructor
    3. accessor functions
    4. mutator functions
ANSWER: B
  1. 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;
};
    1. ItemClass() myItem;
    2. ItemClass myItem(1, 0.0);
    3. ItemClass myItem;
    4. ItemClass myItem();
    5. You can not do this

ANSWER: C





































No comments:

Post a Comment

Linkwithin

Related Posts Plugin for WordPress, Blogger...