Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in C++ Suppose that the alphabets are given the following values: a=1, b=2, c=3, ..., z=26. Using this rule, we define the value of a

in C++

Suppose that the alphabets are given the following values: a=1, b=2, c=3, ..., z=26. Using this rule, we define the value of a word as the sum of the values of its letters. Thus, the value of the word cat is c+a+t = 3+1+20 = 24. Furthermore, the value of the phrase "a cat" is a+c+a+t=1+3+1+20=25.

The value of a sentence, paragraph, and any larger unit of writing is similarly defined. When we compute such values, we ignore any non-alphabetic characters. We also ignore upper and lower case differences; thus, A Cat? has the same value as a caT. The following program prints out the value of the sentence "a cat":

#include

using namespace std;

int main() {

// define the variables int c=3, a=1, t=20;

// compute the value int value = a+c+a+t;

// print out the result cout << value << endl;

return 0;

}

This project involves a passage from John Miltons Paradise Lost:

Likening his Maker to the grazed ox, Jehovah, who in one night, when he passed From Egypt marching, equalled with one stroke Both her first-born and all her bleating gods.

Given the stated rules, this passage has a value. Let us define modified passage as a passage where all the letters of a persons first name are taken out from the main passage.

For a student named Jane Doe (first name is Jane), if she starts of with Paradise Lost passage, her modified passage will be:

Likig his Mkr to th grzd ox, hovh, who i o ight, wh h pssd From gypt mrchig, qulld with o strok Both hr first-bor d ll hr bltig gods.

(notice: there are no occurrences of the letters j, a, n, and e above) For Jane, the value of her modified passage is: 1276

Computing this value manually can be difficult and error-prone especially, when the number of letters is large. A better approach is to write a program that can do it for us. What is the value of a modified passage if you take out all the letters, from the Paradise Lost passage? write a program to compute this value. Your program should only print the answer (a number).

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

Step: 3

blur-text-image

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

Database Processing Fundamentals Design

Authors: Marion Donnie Dutton Don F. Seaman

14th Edition Globel Edition

1292107634, 978-1292107639

More Books

Students also viewed these Databases questions