Instructions The program Telephone Digits outputs only telephone digits that correspond to uppercase letters. Rewrite the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Instructions 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). ****// I 2 // Program: Telephone Digits 3 // This is an example of a sentinel-controlled loop. This 4 // program converts uppercase letters to their corresponding 5 // telephone digits. 6 //***** 7 #include <iostream> 8 9 using namespace std; 10 11 int main() 12 { 13 14 15 16 17 34 FREE 18 19 20 21 22 23 24 25 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; 11 26 27 28 283 29 30 31 32 33 34 35 36 37 38 39 40 1 Q 43 44 45 46 47 48 49 42 46 while (letter != '#') { cout << "Letter: "<< letter; cout << ", Corresponding telephone digit: "; num = static_cast<int>(letter) static_cast <int> ('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; } else cout <<digit << endl; cout << "Invalid input." << endl; 50 51 52 53 54 55 56 -57 58 59 60 61 62 } cout <<"\nEnter 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; Instructions 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). ****// I 2 // Program: Telephone Digits 3 // This is an example of a sentinel-controlled loop. This 4 // program converts uppercase letters to their corresponding 5 // telephone digits. 6 //***** 7 #include <iostream> 8 9 using namespace std; 10 11 int main() 12 { 13 14 15 16 17 34 FREE 18 19 20 21 22 23 24 25 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; 11 26 27 28 283 29 30 31 32 33 34 35 36 37 38 39 40 1 Q 43 44 45 46 47 48 49 42 46 while (letter != '#') { cout << "Letter: "<< letter; cout << ", Corresponding telephone digit: "; num = static_cast<int>(letter) static_cast <int> ('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; } else cout <<digit << endl; cout << "Invalid input." << endl; 50 51 52 53 54 55 56 -57 58 59 60 61 62 } cout <<"\nEnter 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;
Expert Answer:
Answer rating: 100% (QA)
You can modify the program to handle both uppercase and lowercase letters and output the correspondi... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
Ms. Planner is in the 25% tax bracket and itemizes on her tax return. She plans to make a charitable contribution of $12,000 to her alma mater this year. What is the net cost of this contribution to...
-
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...
-
The site http://virtualpiano.net features an online player piano. If you click on the Key Assist menu just above the piano keyboard, and then Keyboard Keys, you will see that each key is labelled...
-
Debbie plans to buy a house for cash instead of paying a mortgage. She is willing to set aside $12 000 at the end of each year for 15 years. She puts her savings in a Tax Free Savings Account (TFSA)...
-
The homogeneous semi cylinder has a mass m and mass center at G. Determine the largest angle of the inclined plane upon which it rests so that it does not slip down the plane. The coefficient of...
-
Sylvia is interested in financial laws and regulations. She enjo make sure they are in compliance with laws and regulations. career should Sylvia consider?
-
If each point of the sample space of Figure 3.12 represents an outcome having the probability find, 32
-
Prepare all journal entries (budgetary and actual) required in all funds and the GCA-GLTL accounts to record the following transactions and events: 1. The county sold old equipmentoriginal cost...
-
Vaughn Company uses the perpetual method, a sales journal, a cash receipts journal, and a general journal to record transactions with its customers. The cost of all merchandise sold was 65% of the...
-
La-Z-Boy Incorporated included the following information in its 2009 annual report (dollars in millions). Define solvency and discuss how this information might be useful in assessing the company??s...
-
When market prices are much higher than fundamental or rational analysis would tend to support, the market is said to be in a(n): 1. fantasy land. 2. inverted state. 3. bubble. 4. winners state. 5....
-
How can index futures be used to change the beta of a well-diversified portfolio?
-
Explain how LIBOR is determined and why it is being discontinued.
-
How is the formula for the minimum variance hedge ratio changed to take account of daily settlement?
-
Explain what liquidity preference theory and expectations theory imply about forward interest rates and expected future spot interest rates.
-
What is the relationship between the quoted price and cash price of a Treasury bill?
-
Which describes a platform? an organized collection of data stored electronically on a local computer system or cloud a ready-to-use software package that performs a specific business function a...
-
I frequently use NY Times and CNN and am aware of Fox News but I never use it. I visit these sites, NY Times and CNN, a few times a week whenever I have to research something or see something on...
-
Modify the Bouncing Ball example from Listing 9.18, except instead of animating a red circle, animate an image of your choice. Listing 9.18 import javafx.application.Application; import...
-
Write a program that reads a line of text and then displays the line, but with the first occurrence of hate changed to love. For example, a possible sample dialogue might be Enter a line of text. I...
-
Programming Project 2 asks you, among other things, to write a program that creates a binary file of objects of the class Species. Write a program that reads from a file created by that program and...
-
Personalized medicine may be used a. to characterize types of tumors. b. to predict the outcome of certain types of cancers. c. to determine the proper dosage of drugs. d. in all of the above.
-
Tumor-suppressor genes promote cancer when a. they are overexpressed. b. they are expressed in the wrong cell type. c. their function is inactivated. d. they are expressed at the wrong stage of...
-
Which of the following is a type of genetic change that could produce an oncogene? a. Missense mutation b. Gene amplification c. Chromosomal translocation d. All of the above can produce an oncogene.
Study smarter with the SolutionInn App