首页
编程语言
数据库
网络开发
Algorithm算法
移动开发
系统相关
金融统计
人工智能
其他
首页
>
> 详细
CSE278讲解、辅导Software、讲解C++语言、c/c++编程设计调试 讲解Python程序|讲解留学生Processing
CSE278 SYSTEMS 1
Department of Computer Science and Software Engineering
Miami University
Spring 2020
Mid Term Exam
March 12, 2020
Full Marks: 100
There are 15 Questions for a total of 100 points.
Answer ALL the questions
NAME: MUID:
General Instructions
First, ensure you have all the 10 pages of this exam booklet even before starting
This exam is closed notes and closed books. No discussions are permitted
You may use Calculator
Do not bring out your cell phone; don’t answer the phone; don’t read text messages
You have 2 hours to complete the exam
Write your answers clearly
The size of the space given for each answer is sufficient
Write no more than 3-4 lines for each of the short questions
Show all your works for the Mathematical problems
Even if your final answers are incorrect, you will get partial credit if intermediate steps are clearly shown to highlight thought process. This applies to program tracing questions as well.
Good Luck!
SHORT QUESTIONS.
[5 * 10 = 50 point]
1.Briefly (1 to 2 sentences each) state the 4 key principles of object-oriented programming
2.Elaborate the meaning of the following as well as mention the port number that they use:
Protocol Elaborated meaning Port Number
SMTP
3.For a communication session between a pair of processes, which process is the client and which is the server?
4.What information is used by a process running on one host to identify a process running on another host?
5.What is the difference between unordered_map and vector?
6.What do you understand by the term CSV? Consider the following contents of a file, faculty.txt:
054, Campbell
103, Kiper
112, Rao
a.What UNIX/Linux command can be used to produce a output, list just the faculty names:
Campbell
b.What C++ function/code that can be used to produce the similar output for the above. Make necessary assumptions.
7.How is a well-known port different from an ephemeral port?
8.A user on the host 170.210.17.145 is using a Web browser to visit www.example.com. In order to resolve the www.example.com domain to an IP address, a query is sent to an authoritative name server for the “example.com” domain. In response, the name server returns a list of four IP addresses in the following order {192.168.0.1, 128.0.0.1, 200.47.57.1, 170.210.17.130}. Even though it is the last address in the list returned by the name server, the Web browser creates a connection to 170.210.17.130. Why?
9.A Host has an IP address of 10001000 11100101 11001001 00010000. Find the class and decimal equivalence of the IP address.
10.Draw a TCP/IP Internet that consists of two networks connected by a router. Show a computer attached to each network. Show the protocol stack used on the computers and the stack used on the router
C++ Coding Problems
11. [10] Develop a simple C++ program that:
a. Reads words (separated by whitespace only and not any other punctuation or special characters) from the user until logical end-of-file
b. Prints the just the count of words (just one integer and no other text/messages) that start with an English vowel, i.e., one of: AEIOUaeiou characters.
For example, given just the sentence “Elephants are Awesome animals” the output will be 4. Similarly, for the input “I think I am warming up to C++” the output is also 4.
12.[5] Assume that a system has a 32-bit virtual address with a 4-KB ( 1 KB = 1024) page size. Write a C++ program that is passed a virtual address (in decimal) on the command line and have it output the page number and offset for the given address. As an example, your program would run as follows:
./a.out 19986
Your program would output:
The address 19986 contains:
page number = 4
offset = 3602
13.[10] Complete the following method that returns a vector with only odd values in the src vector. If the src vector has values {2, -4, 7, 9, 3, 8} this method should return a vector with values {7, 9, 3}.
using IntVec = std::vector
;
IntVec odds(const IntVec& src) {}
14.[10] File I/O using file streams
Develop a C++ program that prints the first line of each paragraph in a given text file specified as command-line argument. Paragraphs are separated by one or more blank (i.e., empty) lines.
a. In order gain practice working with generic I/O streams, add the following method that works with abstract streams to your starter code:
void printFirstLine(std::istream& is, std::ostream& os)
The above method is the one that should process lines from input stream is (use std::getline to read lines) and print first line of each paragraph to output stream os.
b. Call the printFirstLine method (from main) with a suitable std::ifstream to process data from a given text file specified as a command-line argument. Recollect that the file name will be in argv[1] in the main method. Use std::cout as the output stream.
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
void printAllLine(std::istream& is, std::ostream& os){
std::string line;
while (std::getline(is, line)) {
std::cout << line << std::endl;
}
}
void printLastLine(std::istream& is, std::ostream& os) {
std::string line, prevLine;
while (std::getline(is, line)) {
if (line.empty() && !prevLine.empty())
//std::cout << prevLine << std::endl;
os << prevLine << std::endl;
prevLine = line;
}
if (!prevLine.empty()) {
//std::cout << prevLine << std::endl;
os << prevLine << std::endl;
}
}
std::vector
split (const std::string& line){
std::vector
words;
std::istringstream is(line);
std::string word;
const char delimiter = ' ';
while (std::getline(is, word, delimiter)){
words.push_back(word);
}
return words;
}
int main(int argc, char** argv) {
std::vector
myVector;
std:string myLine = "This is a test line to split";
std::ifstream paras(argv[1]);
std::ofstream parasOut(argv[2]);
//printAllLine(paras, std::cout);
printLastLine(paras, parasOut);
myVector = split(myLine);
for (auto word: myVector){
std::cout << word << std::endl;
}
return 0;
}
15. [15] Consider the following GradeBook class definition and implementation:
// Fig. 3.11: GradeBook.h GradeBook class definition. This file presents GradeBook's public
//interface without revealing the implementations of GradeBook's member
// functions, which are defined in GradeBook.cpp.
#include
// class GradeBook uses C++ standard string class
using std::string;
// GradeBook class definition
class GradeBook
{
public:
GradeBook( string ); // constructor that initializes courseName
void setCourseName( string ); // function that sets the course name
string getCourseName(); // function that gets the course name
void displayMessage(); // function that displays a welcome message
private:
string courseName; // course name for this GradeBook
}; // end class GradeBook
// Fig. 3.12: GradeBook.cpp
// GradeBook member-function definitions. This file contains
// implementations of the member functions prototyped in GradeBook.h.
#include
using std::cout;
using std::endl;
#include "GradeBook.h" // include definition of class GradeBook
// constructor initializes courseName with string supplied as argument
GradeBook::GradeBook( string name )
{
setCourseName( name ); // call set function to initialize courseName
} // end GradeBook constructor
// function to set the course name
void GradeBook::setCourseName( string name )
{
courseName = name; // store the course name in the object
} // end function setCourseName
// function to get the course name
string GradeBook::getCourseName()
{
return courseName; // return object's courseName
} // end function getCourseName
// display a welcome message to the GradeBook user
void GradeBook::displayMessage()
{
// call getCourseName to get the courseName
cout << "Welcome to the grade book for\n" << getCourseName()
<< "!" << endl;
} // end function displayMessage
(Modifying Class GradeBook) Modify class GradeBook as follows:
a.Include a second string data member that represents the course instructor’s name.
b.Provide a set function to change the instructor’s name and a get function to retrieve it.
c.Modify the constructor to specify two parameters – one for the course name and one for the instructor’s name.
d.Modify member function displayMessage such that it first outputs the welcome message and course name, then outputs “This course is presented by:” followed by the instructor’s name.
Use your modified class in a test program that demonstrates the class’s new capabilities.
联系我们
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-21:00
微信:codinghelp
热点文章
更多
mgt202辅导 、讲解 java/pytho...
2025-06-28
讲解 pbt205—project-based l...
2025-06-28
辅导 comp3702 artificial int...
2025-06-28
辅导 cs3214 fall 2022 projec...
2025-06-28
辅导 turnitin assignment讲解...
2025-06-28
辅导 finite element modellin...
2025-06-28
讲解 stat3600 linear statist...
2025-06-28
辅导 problem set #3讲解 matl...
2025-06-28
讲解 elen90066 embedded syst...
2025-06-28
讲解 automatic counting of d...
2025-06-28
讲解 ct60a9602 functional pr...
2025-06-28
辅导 stat3600 linear statist...
2025-06-28
辅导 csci 1110: assignment 2...
2025-06-28
辅导 geography调试r语言
2025-06-28
辅导 introduction to informa...
2025-06-28
辅导 envir 100: introduction...
2025-06-28
辅导 assessment 3 - individu...
2025-06-28
讲解 laboratory 1讲解 留学生...
2025-06-28
辅导 ct60a9600 renewable ene...
2025-06-28
辅导 economics 140a homework...
2025-06-28
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 99515681 微信:codinghelp
© 2024
www.7daixie.com
站长地图
程序辅导网!