Engineering Problem Solving With C++ 4th Edition Etter Solutions Manual 1
Engineering Problem Solving With C++ 4th Edition Etter Solutions Manual 1
Exam Practice!
True/False Problems
1. F
2. F
3. F
4. F
5. F
Multiple-Choice Problems
6. (b)and(c)
7. (c)
Memory Snapshot Problems
8. int i->0 int j->0
double x->1.0 double y->5.2
char ch1->a char ch2->,
9. int i->5 int j->0
double x->1.0 double y->?
char ch1->? char ch2->?
10. int i->1 j->5
double x->? double y->?
char ch1->. char ch2->2
11. int i->1 int j->5
double x->0.2 double y->?
char ch1->a char ch2->,
Programming Exercises
Data Filters
/*--------------------------------------------------------------------*/
/* Problem chapter5_12 */
/* */
/* This program reads a data file that should contain only integer */
/* values, and thus should contain only digits, plus or minus */
#include <iostream>
#include <fstream>
#include <string>
#include <cctype>
int main()
{
// Declare variables.
int counter=0;
char c;
string filename;
ifstream file1;
if(file1.fail())
{
cerr << "error opening file " << filename;
exit(1);
}
// Print results.
cout << endl << "Number of invalid characters is: " << counter << endl;
/*--------------------------------------------------------------------*/
/* Problem chapter5_13 */
/* */
/* This program reads a file that contains only integers and white */
/* space. The program prints the number of lines and the number of */
/* integer values. */
#include <iostream>
#include <fstream>
#include <cctype>
#include <string>
int main()
{
// Declare variables.
char c;
int i, linenum(0), integers(0);
ifstream oldfile;
string inname;
oldfile >> i;
while (!oldfile.eof()) {
integers++;
oldfile >> i;
}
/*--------------------------------------------------------------------*/
/* Problem chapter5_14 */
/* *
/* This program reads a file that contains only integers, but */
/* some of the integers have embedded commas, as in 145,020. The */
/* program copies the information to a new file, removing any */
/* commas from the information. */
#include <iostream>
#include <fstream>
#include <cctype>
#include <string>
int main()
{
// Declare variables.
char c;
ofstream newfile;
ifstream oldfile;
string inname, outname;
// Look for commas, and write the data to the new file.
c = oldfile.get();
while(!oldfile.eof())
{
if ( c != ',')
newfile << c;
c = oldfile.get();
}
/*--------------------------------------------------------------------*/
/* Problem chapter5_15 */
/* */
/* This program reads a file containing integer and floating-point */
/* values seperated by commas, which may or may not be followed */
/* by additional white space. A new file is generated that contains */
/* the integers and floating-point values seperated only by a */
/* single space between the values. */
#include <iostream>
#include <fstream>
#include <cctype>
#include <string>
int main()
{
// Declare variables.
char c;
string inname, outname;
ofstream newfile;
ifstream oldfile;
Das Cover wurde vom Bearbeiter den ursprünglichen Bucheinbänden der Serie
nachempfunden und der public domain zur Verfügung gestellt.
Die kräftig variierende Transliteration russischer Namen wurde beibehalten. Der Name
Семёнов kann so z. B. als Semjonow, Ssemjonow oder Semenow auftauchen. Hier ist eine
Liste der am häufigsten gefundenen Varianten:
Altowski, Altowsky
Awksentijew, Awksentiew, Awxentijew
Daschewski, Daschjewskij
Dobroljubow, Dobrolubow
Donskoj, Donskoi
Elkind, Eljkind
Eugenia, Eugenie
Fanny, Fanni
Fedorowitsch, Federowitsch
Fjedorow, Fedorow, Federow
Gerstejn, Gerstein
Grigorij, Grigori
Ignatjew, Ignatiew
Konoplewa, Konopleva, Konopljewa
Koslow, Kozlow
Lew, Lev
Michailowitsch, Michajlowitsch
Murawjew, Murawiew
Nishnij, Nishni
Sawinkow, Savinkow
Semjonow, Ssemjonow, Semenow
Sergejew, Ssergejew
Timofejew, Timofjejew
Utgow, Utgoff
Wolodarskij, Wolodarski
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation
makes no representations concerning the copyright status of any
work in any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™
work in a format other than “Plain Vanilla ASCII” or other format
used in the official version posted on the official Project
Gutenberg™ website (www.gutenberg.org), you must, at no
additional cost, fee or expense to the user, provide a copy, a means
of exporting a copy, or a means of obtaining a copy upon request, of
the work in its original “Plain Vanilla ASCII” or other form. Any
alternate format must include the full Project Gutenberg™ License
as specified in paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive from
the use of Project Gutenberg™ works calculated using the method
you already use to calculate your applicable taxes. The fee is owed
to the owner of the Project Gutenberg™ trademark, but he has
agreed to donate royalties under this paragraph to the Project
Gutenberg Literary Archive Foundation. Royalty payments must be
paid within 60 days following each date on which you prepare (or
are legally required to prepare) your periodic tax returns. Royalty
payments should be clearly marked as such and sent to the Project
Gutenberg Literary Archive Foundation at the address specified in
Section 4, “Information about donations to the Project Gutenberg
Literary Archive Foundation.”
• You provide a full refund of any money paid by a user who notifies
you in writing (or by e-mail) within 30 days of receipt that s/he does
not agree to the terms of the full Project Gutenberg™ License. You
must require such a user to return or destroy all copies of the works
possessed in a physical medium and discontinue all use of and all
access to other copies of Project Gutenberg™ works.
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES
OF MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.
Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.