## Design A Program That Asks The User To Enter A Store S Sales For Each Day Of The Week

5. Alphabetic Telephone Number Translator

Many companies use telephone numbers like 555-GET-FOOD so the number is easier for their customers to remember. On a standard telephone, the alphabetic letters are mapped to numbers in the following fashion:

A, B, and C = 2 D, E, and F = 3 G, H, and I = 4 J, K, and L = 5 M, N, and O = 6 P, Q, R, and S = 7 T, U, and V = 8 W, X, Y, and Z = 9

Write a program that asks the user to enter a 10-character telephone number in the format XXX-XXX-XXXX. The application should display the telephone number with any alphabetic characters that appeared in the original translated to their numeric equivalent. For example, if the user enters 555-GET-FOOD the application should display 555-438-3663.

### 6. Average Number of Words

On the student CD you will find a file named text.txt. The text that is in the file is stored as one sentence per line. Write a program that reads the file's contents and calculates the average number of words per sentence.

(If a CD did not come with your book, or you cannot locate your CD, you can visit www.aw.com/cssupport to access this file.)

7. Character Analysis

On the student CD you will find a file named text.txt. Write a program that reads the file's contents and determines the following:

• The number of uppercase letters in the file

• The number of lowercase letters in the file

• The number of digits in the file

• The number of whitespace characters in the file

(If a CD did not cotne with your book, or you cannot locate your CD, you can visit www.aw.com/cssupport to access this file.)

### 8. Total Sales

Design a program that asks the user to enter a store's sales for each day of the week. The amounts should be stored in a list. Use a loop to calculate the total sales for the week and display the result.

### 9. Lottery Number Generator

Design a program that generates a seven-digit lottery number. The program should generate seven random numbers, each in the range of 0 through 9, and assign each number to a list element. (Random numbers were discussed in Chapter 6.) Then write another loop that displays the contents of the list.

### 10. Rainfall Statistics

Design a program that lets the user enter the total rainfall for each of 12 months into a list. The program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest amounts.

### 11. Number Analysis Program

Design a program that asks the user to enter a series of 20 numbers. The program should store the numbers in a list and then display the following data:

• The lowest number in the list

• The highest number in the list

• The total of the numbers in the list

• The average of the numbers in the list

### 12. Charge Account Validation

On the student CD you will find a file named charge_accounts . txt, This file has a list of a company's valid charge account numbers. Each account number is a seven-digit number, such as 5658845.

Write a program that reads the contents of the file into a list. The program should then ask the user to enter a charge account number. The program should determine whether the number is valid by searching for it in the list. If the number is in the list, die program should display a message indicating the number is valid. If the number is not in the list, the program should display a message indicating the number is invalid.

(If a CD did not come with your book, or you cannot locate your CD, you can visit www.aw.com/cssupport to access this file.)

+1 -2

### Responses

• Arabella
How to design a program that asks the user to enter a charge account number?
7 years ago