Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

write a program 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

write a program 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.

#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.

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 with AI-Powered 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

Students also viewed these Databases questions

Question

What is the formula to calculate the mth Fibonacci number?

Answered: 1 week ago