C++_HW7_Solutions - Eng101W07 Sec 100 Homework 7: Some more...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Eng101W07 Sec 100 Homework 7: Some more Caesar and Strange vectors Due Friday, March 23, 2007, by 6 PM EDT Upload to CTools Site Name: FILL-IN Lab GSI: FILL-IN Lab Section #: FILL-IN A. Preparatory work . Read through Eckel’s Chapter 3. Pay particular attention to functions and the syntax of functions, operators, and looping structures. When in doubt, look things up on http://www.cplusplus.com/reference/ and look at the example code under the member function (skip the front stuff – drop to the bottom of the page). Don’t be disappointed, the length of this assignment has been cut but the points remain the same. Use the sample code provided and use it liberally!
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
B. Answer the following questions. 1. [50 pts.] Decoding the Caesar cipher. a. [10 pts.] Modify your encrypting code from HW6, Problem 3, so that the computer picks the offset at random and writes the encrypted file to disk and the random offset (the key ) to a separate file on disk. Provide a copy of the following parts of your code below: your include files, the code that computes the offset, and the code that encrypts the text. As before, use the Virgil Latin text from HW6. [Hint: on the cplusplus reference site, read about the rand, srand, and the % operator. You’ll want to program your code so that the offset is some number between 1 and 25, instead of “13” as in HW6.] [Note – I’m including all of the code, rather than the specific parts that were required. - ghw]
Background image of page 2
b. [15 pts.] Write a program that counts the number of times each letter of the alphabet occurs in an input text file. Use a vector of integers to store the count as you search through the input file, i.e., given vector< int> alphacount; alphacount[0] stores the number of “a”s, alphacount[1] stores the number of “b”s, etc. Note: You should collapse your count across upper- and lower-case letters, i.e., alphacount[0] should include both the occurrence of “A” and “a”. Write the values of alphacount to a separate file on disk as well as to the console. Include a copy of your code below and the console output when the input file is the Virgil text used in HW6.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
36321 5285 14840
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/04/2008 for the course ENGR 101 taught by Professor Ringenberg during the Fall '07 term at University of Michigan.

Page1 / 12

C++_HW7_Solutions - Eng101W07 Sec 100 Homework 7: Some more...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online