Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete Chapter 7 Programming Project 1 of our text (it is on page 571 of our text, 8th edition). Name your file C7PP1.java. HINT: This

Complete Chapter 7 Programming Project 1 of our text (it is on page 571 of our text, 8th edition). Name your file C7PP1.java.

HINT: This project is really rather simple. Review the section "Wrapper Classes" in Chapter 6 of our text (it starts on page 413), pay specific attention to the methods of the Class Character (on page 416 of our text) - they will be very useful.

HINT: Remember the method charAt of the String class - it returns the character at a specific position in a String.

HINT: Remember ASCII Code - there is a value associated with every character, the character 'a' has an ASCII value of 97, the character 'A' has an ASCII value of 65. The ASCII value of a character can be found by casting the character into an int like this:

(int)'a';

HINT: To get the index position of the character in the assignment array:

If a character is an upperCase character you subtract 65 from its' ASCII value

If a character is a lowerCase character you subtract 97 from its' ASCII value

If I give you any more hints I will be doing the assignment for you.

Write a program that will read a line of text that ends with a period, which serves as a sentinel value. Display all the letters that occur in the text, one per line and in alphabetical order, along with the number of times each letter occurs in the text. Use an array of base type int of length 26, so that the element at index 0 contains the number of a's, the element at index 1 contains the number of b's, and so forth. Allow both uppercase and lowercase letters as input, but treat uppercase and lowercase versions of the same letters as being equal. (Hint: Use one of the methods toUpperCase or toLowerCase in the wrapper class character, described in Chapter 6. you will find it helpful to define a method that takes a character as an argument and returns an int value that is the correct index for that character. For example, the argument 'a' result in 0 as the return value, the argument 'b' gives 1 as the return value, and so on. Note that you can use a type cast, such as (int) letter, to changed a char to an int. Of coarse this will not get the number you want, but if you subtract (int) 'a', you will then get the right index) Allow the user to repeat this task until the user says she or her is through.

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

More Books

Students also viewed these Databases questions

Question

Define Administration and Management

Answered: 1 week ago

Question

Define organisational structure

Answered: 1 week ago

Question

Define line and staff authority

Answered: 1 week ago

Question

2 What supply is and what affects it.

Answered: 1 week ago

Question

3 How supply and demand together determine market equilibrium.

Answered: 1 week ago