Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Introduction to Programming It is short and simple practice. Please solve #1

ID: 3775535 • Letter: C

Question

C++ Introduction to Programming

It is short and simple practice.

Please solve #1,2,3,4,5

#include<iostream>

...

Classes: members and methods
Classes, continued: access specifiers and constructors
Classes for object oriented design
Recursion
Multi-file projects and header files
Exceptions, tests, and assertions
Assertions, Advanced Input/Output
Operator Overloading; Inheritance and Abstract data types

int main( int i Cin try t if(i throw out of range; throw system error; catch (logic error& e cout LE catch cout "Unknown" return 0 User enters 1: YOUR ANSWER HERE User enters 2 YOUR ANSWER HERE 2. What is wrong with the following exception-handling code? try Do whatever catch (exception& e Handle exception catch (logic error& e) Handle logic error catch (domain error& e) Handle out-of-range Suppose we have a project consisting of four files 3. main.cpp, Core.cpp utilities.cpp and tools.cpp There are two header files: core h includes declarations for functions in core.cpp tools h includes declarations for functions in both utilities.cpp and tools cpp ain .cpp uses functions fro core cpp and tools core.cpp uses functions from tilit pp and tool pp What #includes should be listed at the top of main.cpp? YOUR ANSWER HERE What #includes should be listed at the top of core.cpp? YOUR ANSWER HERE What commands do we give to compile this entire project into a single executable named "core utilities"? YOUR ANSWER HERE h of the foll th t belong pp) tat h) file header or both Function declaration YOUR ANSWER HERE Class definition: YOUR ANSWER HERE Method definition YOUR ANSWER HERE Function definition YOUR ANSWER HERE 5. On the server, there is a file located in "/usr/share/dict/words" that contains a dictionary of English words about 100,000 of them, one per line. rite a program which opens this file and counts the number of lines (words) in it YOUR ANSWER HERE

Explanation / Answer

1.
User enters 1 :prints the LE
User enters 2 :prints the Unknown

2.
try
{

}
catch(domain_error& e)
{

}
catch(logic_error& e)
{

}
catch(exception& e )
{


}
exception is the base for all exceptions that is handeled at the last catch block

3.
a) #include"tools.h" and #include"core.h" should be included in the main.cpp file
b) core.cpp file should included #include"core.h"

4.
Function Declaration: .h
Class Definition : .h and .cpp
Method Definition: .cpp
Function Definition: .cpp

//5.
#include <iostream>
#include <fstream>

using namespace std;

int main()
{

int number_of_lines = 0;
string line;
ifstream myfile("wordfile.txt");
while (myfile.good ())
{
getline(myfile, line);


++number_of_lines;


}
cout << "Number of lines is "<<number_of_lines<< endl;
return 0;
}
wordfile.txt
word1
word2
word3
word4
word5

OUTPUT:

Number of lines is 5

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote