Concept explainers
(Telephone-Number Word Generator) Standard telephone keywords contain the digits 0 through 9. The numbers 2 through 9 each have three letters associated with them, as is indicated by the following table:
Digit Letter | Digit Letter |
2 ABC 3 DEF 4 GHI 5 JKL |
6 MNO 7 PQRS 8 TUV 9 WXYZ |
Fig. 14.18 Telephone digit-to-letter mappings.
Many people find it difficult to memorize phone numbers, so they use the correspondence between digits and letters to develop seven-letter words that correspond to their phone numbers. For example, a person whose telephone number is 686-2377 might use the correspondence indicated in the above table to develop the seven-letter word "NUMBERS."
Businesses frequently attempt to get telephone numbers that are easy for their clients to remember. If a business can advertise a simple word for its customers to dial, then no doubt the business will receive a few more calls. Each seven-letter word corresponds to exactly one seven-digit telephone number. The restaurant wishing to increase its take-home business could surely do so with the number 825-3688 (i.e., "TAKEOUT"). Each seven-digit phone number corresponds to many separate seven-letter words. Unfortunately, most of these represent unrecognizable juxtapositions of letters. It's possible, however, that the owner of a barber shop would be pleased to know that the shop's telephone number, 424-7288, corresponds to "HAIRCUT" A veterinarian with the phone number 738-2273 would be happy to know that the number corresponds "PETCARE.”
Write a program that, given a seven-digit number, writes to a file every possible seven-letter word corresponding to that number. There are 2187 (3 to the seventh power) such words. Avoid phone numbers with the digits 0 and 1.
Want to see the full answer?
Check out a sample textbook solutionChapter 14 Solutions
C++ How to Program (10th Edition)
- Q1) Write a program that • Asks for a natural number (Assume that number is n) • Draws the following triangular shape with n lines of numbers. Example: (n = 5) 1. 2 1 3 21 4 3 2 1 5 4 3 21 (n = 3) 1. 21 3 21 In the triangular shape, There is a space character between each neighboring numbers on the same line. • The rightmost number is supposed to be 1. • The numbers are ordered in a descending order. The ith line should contain i numbers. The numbers are aligned right.arrow_forwardLanguage: JAVA Leap-Year Write a program to find if a year is a leap year or not. We generally assume that if a year number is divisible by 4 it is a leap year. But it is not the only case. A year is a leap year if − It is evenly divisible by 100 If it is divisible by 100, then it should also be divisible by 400 Except this, all other years evenly divisible by 4 are leap years. So the leap year algorithm is, given the year number Y, Check if Y is divisible by 4 but not 100, DISPLAY "leap year" Check if Y is divisible by 400, DISPLAY "leap year" Otherwise, DISPLAY "not leap year" For this program you have to take the input, that is the year number from an input file input.txt that is provided to you. The input file contains multiple input year numbers. Use a while loop to input the year numbers from the input file one at a time and check if that year is a leap year or not. Create a class named LeapYear which will contain the main method and write all your code in the main…arrow_forward9: perfect.cpp) A number is called perfect if the sum of its divisors is equal to the original number. A number is called deficient if the sum of its divisors is less than the original number. A number is called abundant if the sum of its divisors is more than the original number. Write a program that answers the following questions: What numbers below 5000 are perfect? What odd numbers below 5000 are abundant? What are the relative proportions of deficient, abundant, and perfect numbers? 5000 should be in a global constant.arrow_forward
- Leap Year: The earth doesn't take exactly 365 days to revolve around the sun and because of this we have leap years roughly every 4 years to make up the difference. The exact rule is: • Years divisible by 4 are leap years • except if they are also divisible by 100 and then they are not leap years (so 1900 was not a leap year), • unless they are also divisible by 400 and then they ARE leap years (so 2000 was a leap year). Part 1) Write a function in Python that takes as input a number, the year, and determines if it is a leap year or not. The function should return True if it is a leap year and False otherwise. Part 2) Write a main function to test out your leap year function on a few different illustrative inputs.arrow_forwardDiscrete Mathematics: Assignment details: Replace all the 0 (Zero) digits in your ID by 4. Example: If your ID is 38104680, it becomes 38144684 Take the first 6 digits and substitute them in this expression (( A + B) / C) * ((D-E)/F)-2) according to the following table; Letter Replace by Digit Example Digit A 1st 3 B 2nd 8 C 3rd 1 D 4th 4 E 5th 4 F 6th 6 After substitution your expression will be similar to this (( 3 + 8) / 1) * ((4-4)/6)-2). Draw a rooted tree that represents your expression. What is the prefix form of this expression. 3.What is the value of the prefix expression obtained in step 2 above?arrow_forwardHow to attempt? Question : The Card Game One day, Fred and his N friends were playing a card game in which each player throws a card with a number written on it. The cards are such that a number X is written on front of the card, and the negative of that number is written on the back side of the card. This game has the following rules: - Each of the N players is asked to throw a card. After all the N cards are thrown, Fred has to flip one or more cards in consecutive order, only once. Your task is to help Fred flip the cards in such a way that the sum of the numbers, on front face of the cards, is the maximum.arrow_forward
- 7bact1 Please help me answer this in python programming.arrow_forwardVPython 3500) assignments/3090165 Answers to ms to Canvas for the following problems. There should be 7 programs. 4B, 5, 6 1. A. Write a VPython program that creates eight spheres, each placed at one corner of a cube centered on the origin. The length of a side of the cube should be 6 units, and the radius of each sphere should be 0.5. Use at least two different colors for the spheres. B. Add to the program an arrow whose tail is at one corner of the cube and whose tip is at the corner diagonally opposite. The figure below shows the display from one possible solution to this problem. 2. Write a VPython program that represents the x, y, and z axes by three cylinders of different colors. This display from one possible solution is below.arrow_forwardC Language - Given a highway number, indicate whether it is a primary or auxiliary highway. If auxiliary, indicate what primary highway it serves. Also indicate if the (primary) highway runs north/south or east/west.arrow_forward
- fngdndndnn n dnnndnfnfnarrow_forwardAPLarrow_forward11: series.cpp) Write a program that will add the terms of an infinite geometric series. The program should read the first term (a) and the common ratio (r) for the series. It should then compute the sum in two ways: by formula ( s= ), and by adding the individual terms until the answer agrees with the formula to 7 significant digits. Then print the formula answer, the answer found by adding thearrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning