Limited time offer 20% OFF StudySoup Subscription details

KSU - CIS 300 - Study Guide - Midterm

Created by: Laurel Knust Elite Notetaker

KSU - CIS 300 - Study Guide - Midterm

0 5 3 60 Reviews
This preview shows pages 1 - 2 of a 4 page document. to view the rest of the content
background image Name: Model Solution CIS 300 Exam 1 This is a 50-minute closed-book exam. Use your time wisely. No cal- culators or other electronic devices are allowed. Please silence and put
away all phones and put away all watches.
If you run out of room, you may use the backs of these pages. In all code that you write, follow
the the programming style requirements for this course; however, you do
not need to follow the requirements for comments or formatting. For each
question, you will be graded in part on the efficiency of your code. The last
page contains documentation for your reference — you may remove it if you
wish.
1. (20 points) Two private fields are defined below, where the LinkedListCell<T> type is as defined on the last page. Fill in the MoveCell method below to move the first cell of the linked
list given by _firstList to the beginning of the linked list given by
_secondList
. For example, if _firstList refers to a list containing the sequence h10, 20, 30i, and _secondList refers to a list contain-
ing the sequence h1, 2, 3, 4i, then calling MoveCell should cause
_firstList
to refer to a list containing h20, 30i, and _secondList to refer to a list containing h10, 1, 2, 3, 4i. If _firstList is null, the
method should throw an InvalidOperationException. You should
assume that there is other code that may have changed the values of
_firstList
and _secondList before MoveCell was called. You may not construct any new LinkedListCells — instead, you must move
an existing cell. You may not add any code outside the MoveCell
method.
private LinkedListCell<decimal> _firstList; private LinkedListCell<decimal> _secondList; private void MoveCell()
{
if (_firstList == null)
{
throw new InvalidOperationException(); }
LinkedListCell<decimal> p = _firstList;
_firstList = _firstList.Next;
p.Next = _secondList;
_secondList = p;
}
background image 2. (45 points) Fill in the method stub below so that it displays the given OpenFileDialog to the user, and if the user selects a file, returns a StringBuilder containing every second character from the selected file. For example, if the user selects a file containing the single line
(there is no white space at the beginning or end):
1234567890 - the ten digits. the method should return a StringBuilder containing, “24680-tetndgt.”. If the user does not select a file, it should return null. If an exception is thrown while the file is being read, the
exception should be displayed in a MessageBox, and null should be
returned. You may assume that fd is not null. You may not add any
code outside of this method.
private StringBuilder GetEverySecondCharacter(OpenFileDialog fd)
{
StringBuilder sb = null;
if (fd.ShowDialog() == DialogResult.OK)
{
try
{
string s = File.ReadAllText(fd.FileName);
sb = new StringBuilder();
for (int i = 1; i < s.Length; i += 2)
{
sb.Append(s[i]); } }
catch (Exception ex)
{
MessageBox.Show(ex.ToString()); } }
return sb;
}

This is the end of the preview. Please to view the rest of the content
Join more than 18,000+ college students at Kansas State University who use StudySoup to get ahead
School: Kansas State University
Department: Computer Information Systems
Course: Algorithms & Data Structures
Professor: Rodney Howell
Term: Summer 2016
Tags: CIS, 300, CIS300, data, programming, structures, C#, code, coding, and Computer
Name: CIS 300 Midterm Exam 1 Study Guide
Description: Midterm study guide for CIS 300
Uploaded: 09/19/2016
4 Pages 62 Views 49 Unlocks
  • Better Grades Guarantee
  • 24/7 Homework help
  • Notes, Study Guides, Flashcards + More!
Join StudySoup for FREE
Get Full Access to KSU - CIS 300 - Study Guide - Midterm
Join with Email
Already have an account? Login here
×
Log in to StudySoup
Get Full Access to KSU - CIS 300 - Study Guide - Midterm

Forgot password? Reset password here

Reset your password

I don't want to reset my password

Need help? Contact support

Need an Account? Is not associated with an account
Sign up
We're here to help

Having trouble accessing your account? Let us help you, contact support at +1(510) 944-1054 or support@studysoup.com

Got it, thanks!
Password Reset Request Sent An email has been sent to the email address associated to your account. Follow the link in the email to reset your password. If you're having trouble finding our email please check your spam folder
Got it, thanks!
Already have an Account? Is already in use
Log in
Incorrect Password The password used to log in with this account is incorrect
Try Again

Forgot password? Reset it here