首页
编程语言
数据库
网络开发
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
热点文章
更多
辅导 cs1b spring 2024 tth hw...
2024-04-19
讲解 managing financial risk...
2024-04-19
辅导 cs 0449 – project 5: /...
2024-04-19
辅导 elec 2141 digital circu...
2024-04-19
讲解 csc171 — videogame pro...
2024-04-19
讲解 comp3411 artificial int...
2024-04-19
讲解 stat3061: random proces...
2024-04-19
辅导 accounting 452, spring ...
2024-04-19
辅导 finc5001 foundations in...
2024-04-19
辅导 7ssmm712 – topics in a...
2024-04-19
讲解 com 337 - film studies ...
2024-04-19
辅导 mes202tc - digital vlsi...
2024-04-19
辅导 geography 2041b distanc...
2024-04-19
辅导 ecos3006 international ...
2024-04-19
讲解 fit5225 2024 sm1 creati...
2024-04-19
讲解 cit 593: introduction t...
2024-04-19
讲解 math 4931: take home ex...
2024-04-19
辅导 csci 547|info 533: syst...
2024-04-19
辅导 cs536-s24 intro to pls ...
2024-04-19
讲解 fit5212 - assignment 1辅...
2024-04-19
热点标签
comm1190
elec9764
acfi3308
acct7101
fin6035
comp2048
geog0163
comp2013
coen 146
dts101tc
sehh2042
comp282
csc1002
comp10002
comp30023
comp27112
comp4880/8880
cs 455
07
stat0045.
fil-30023
celen085
psyc40005
math40082
are271
comp9311
ee5311
imse2113
comp 2322
acct2102
fnd109
int102
is3s664
is6153
data4000
accfin5034
fit5212
cs536-s24
fit5225
ecos3006
mes202tc
finc5001
stat3061
csc171
cs1b
7ssmm712
bu.450.760
comp3411
cs170
swen90004
cpt206
comp5313/comp4313—large
bl5611
kxo206
comp532
elec207
kxo151
cs 2820
cpt108
math2319
dts204tc
qm222
comp2511
ccs599
infs1001
mat2355
eeee4123
25721
ifn647
pols0010
hpm 573
comp9417
stat0023
csci 1100
qbus6860
comp2003j
cse340
cs 2550
cs 61b
cs360
fin 3080
ierg 4080
cs6238
cit 594
finm7406
hw6
elec9713
asb-2522
mso3610
lit301
mcd4540
geog0030
125.330
biol0006
125.320
cs3334
fit2093
acct1101
110.309
masy1-gc
cs314
elec0048
gds104
mg5637
fit2096
math5905
eel4837
sehs4515
cpt s 321
asb2522 investment
ma214
co2104
mgmt2015
32516
math32051
econ1012
mark2052
comp3310
econ0019
dsci 525
abmf3184
aps106
antc27
finm7401
itp122
tech2300
math3026
comp9024
cao107
36318
is2022
cs 211
fit1047
ics4u
2xc3
en.540.635
4qqmn506
finn3081
phys10362
sta601
ec481e
math5165
csi 2120
el1205
comp7250
ecos3013
beam065
info1113
comp2051
csc325
mne 6130
ai6126
ecs150
is61x6
cse115
seng6110
bus265
cpts260
mphy0009
csc306
eco2011
ee3004
inu1111
st332
idepg001
info6001
cpt106
finm7409
fit3152
fins5516
qbus2820
isom3028
eece 6083
ceg5304
mcd4700
eecs 493
eg25h4
38173
elc5216
infs6071
lubs5996m
7ssmm803
glbh0031
phys1120
comp52715
eeb240
math3836
cmns3490
iy5610/4610
cpt304
ac6105
psyc3241
fin570
218.323
lng310
rim3352
bio206
comp3334
soci3403
ac.f633
联系我们
- QQ: 99515681 微信:codinghelp
© 2024
www.7daixie.com
站长地图
程序辅导网!