Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The program Telephone Digits outputs only telephone digits that correspond to uppercase letters. Rewrite the program so that it processes both uppercase and lowercase letters

The program Telephone Digits outputs only telephone digits that correspond to uppercase letters. Rewrite the program so that it processes both uppercase and lowercase letters and outputs the corresponding telephone digit. If the input is something other than an uppercase or lowercase letter, the program must output an appropriate error message (The error message should contain the phrase Invalid input). This the code: //********************************************************** // Program: Telephone Digits // This is an example of a sentinel-controlled loop. This // program converts uppercase letters to their corresponding // telephone digits. //********************************************************** #include using namespace std; int main() { char letter; int digit, num; cout << "Program to convert uppercase letters to " << "their corresponding telephone digits." << endl; cout << "To stop the program enter #." << endl; cout << "Enter an uppercase letter: "; cin >> letter; cout << endl; while (letter != '#') { cout << "Letter: " << letter; cout << ", Corresponding telephone digit: "; num = static_cast(letter) - static_cast('A'); if (0 <= num && num < 26) { digit = (num / 3) + 2; if (((num / 3 == 6 ) || (num / 3 == 7)) && (num % 3 == 0)) digit = digit - 1; if (digit > 9) digit = 9; cout << digit << endl; } else cout << "Invalid input." << endl; cout << " Enter another uppercase " << "letter to find its corresponding " << "telephone digit." << endl; cout << "To stop the program enter #." << endl; cout << "Enter a letter: "; cin >> letter; cout << endl; } //end while return 0; } I tried to type it in but it keep saying error. Please Help

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

Nested Relations And Complex Objects In Databases Lncs 361

Authors: Serge Abiteboul ,Patrick C. Fischer ,Hans-Jorg Schek

1st Edition

3540511717, 978-3540511717

More Books

Students also viewed these Databases questions

Question

g. Is the value of b equal to 0.5? Pg45

Answered: 1 week ago

Question

Explain exothermic and endothermic reactions with examples

Answered: 1 week ago

Question

Write a short note on rancidity and corrosiveness.

Answered: 1 week ago