Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have a c++ assignment to build a string calculator that adds and subtracts bas

ID: 3684573 • Letter: I

Question

I have a c++ assignment to build a string calculator that adds and subtracts based on the ASCII value of the string that is inputted. So far I have the general format of a class declared with my friend function and the definition of the overloading operator of addition and subtraction but I am stuck and don't know what to do next. Below is a sample input and output. Can someone explain to me how to implemenet this? What do I put into the definitions in order to give it the output below? How am i suppose to make it so that it gets the ascii value of each character from the string inputed? I must use operator overloading for this assignment. Can someone please help me get a better idea of how to move on from here?

Input A: hello world

Input B:Hi Tom

A+B= 6TlFdmworld

Explanation / Answer

As per the given input, the ascii values for each character are:

And that for input B is:

And that of the output is:

Can someone explain to me how to implement this?

What do I put into the definitions in order to give it the output below?

From the above logic, we can observe that, if the summation is between 2 alphabets, just add both the ascii values and subtract 122(An ascii value of z) from the summation. And if the summation is between an alphabet and a space, leave the alphabet as it is. And if there is no second character, consider it a space.

How am i suppose to make it so that it gets the ascii value of each character from the string inputed?

From the string inputted, to get the ascii value of a character, you can simply typecast the character to integer. And to access each character in the string, in C++ there is a libray function at(), which takes the index as input, and will return the character at that index in the string. For example str = "Hello", then str.at(0) will return H, str.at(3) will return l, and so on.

I must use operator overloading for this assignment.

Yes. You can use operator overloading in your class, simply by defining the function,

string operator+(String str), a function which takes another object of type string as input, and will operate on this object and given object, and will return the result as output.

Can someone please help me get a better idea of how to move on from here?

Hope this will give you an idea on how to start up. If you have any further queries, just get back to me.

h e l l o w o r l d 104 101 108 108 111 32 119 111 114 108 100