Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

C++ programming assignment due Sunday at midnight that I'm struggling with leave a comment if u have any questions and I will try to explain

C++ programming assignment due Sunday at midnight that I'm struggling with

leave a comment if u have any questions and I will try to explain but essential you are using two classes in order to decode a string entered into in by the user, the way it is decoded is by reading in digraphs from a big text file doesn't matter what one it just reads it in and scores it then decodes that way.

the file at the bottom is the syntax checker

thanks for any help

image text in transcribedimage text in transcribedimage text in transcribed

WAYNE'S ANNOYING RECTANGULAR TRANSPOSITION. Wayne likes to send messages by first writing them in a rectangle row-wise, and then reading them off column-wise. Example: When Orange rules" is encoded in a rectangle of width 4, oran ger ules one gets "Ogurela enrs". The goal is a program that can decode a sentence that has been encoded using a rectangle of unknown width. 1) Initial version of class Wart You should start with a Wart class (stored in .cpp and .h of the same name). The class stores a phrase in a string member variable. It should initially have at least the following: a constructor that takes a string a void encode (int) function that takes the width and changes the stored string. Note that if the length of the string is not a multiple of width, then the string should be padded with periods so that the length becomes a multiple of width. For example, when "Orange rules is encoded in a rectangle of width 5, the result is "Oeer sar.nu.gl.. an overloaded stream insertion operator for output a destructor if needed 2) Class Digraph The decoding will choose the version that is "closest" to English. In order to do the decoding, we need the relative proportions of digraphs in English. A digraph is an ordered pair of consecutive letters within the same word. Create a class Digraph (stored in files of the same name) that stores these proportions. The class should be case-insensitive, and should scale the proportions so that they sum to 1. The Digraph class should have at least the following: a no-argument constructor that sets the proportions to 0.1 for each of th he in eran rend at on nt and 0.0 for every other digraph. a constructor that takes the name of a text file, and uses that file to determine the proportions. The constructor should print out the digraph with highest proportion. a function double getScore(char, char) that takes two chars and returns the proportion associated with that digraph. (Case-insensitive) a function double getScorel & string ) that takes a string and returns the sum of the proportions associated with each consecutive pair of characters. (If either character is not a letter then its score is zero.) a destructor if needed 3) Doing the decoding Implement a primitive decoding method. For this, you need to add one public function to your Wart class (but you might choose to also add a private function or two). A void function decode(&Digraph): Say the current string has length m. Then try all possible widths from 1 up to m inclusive, but only those that are divisors of m. For each possible width, determine the score the Digraph gives. After considering all possibilities, change the stored string to the decoding that gives the highest score. (Ties can be broken arbitrarily.) 4) Driver file Create a driver file Runner.cpp that: reads a file name from user and creates a Digraph using that file; reads the encoded sentence from the user (not the command line) and creates a Wart; . then invokes the decode function and prints out the resultant Wart. Here is a sample run: Make sure that your output is similar. Enter file name for digraph: kafka.txt Most common was: he with a proportion of 3591/83508 = 0.0430019 Enter sentence terminated by Ogurela enrs This gets a score of: 0.0508215 The decoded sentence is: Orange rules #include using namespace std; #include "Wart.h" int main() Wart w("Cogito ergo sum"); w.encode( 3 ); cout Ogurela enrs This gets a score of: 0.0508215 The decoded sentence is: Orange rules #include using namespace std; #include "Wart.h" int main() Wart w("Cogito ergo sum"); w.encode( 3 ); cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL/PHP Database Applications

Authors: Jay Greenspan, Brad Bulger

1st Edition

978-0764535376

More Books

Students explore these related Databases questions

Question

What attracts you about this role?

Answered: 3 weeks ago

Question

How many states in India?

Answered: 3 weeks ago