[SOLVED] SOLVED: Create a New Project named StringDemo

20.00 $

Programming resource
Digital learning resource
Category:
Practical programming resource
Suitable for guided study and reference
Tutor guidance available when needed

Description

5/5 - (1 vote)

Lab 9 Text Processing Objectives Learn how to use String methods Key Concepts 􀁸 The String class provides several methods for working with String objects. Lab Assignment This lab assignment will ask you to write a program prints a String object backward and counts the number of words it contains. Exercise 1 1. Create a New Project named StringDemo 2. Write a method called “backward()” that accepts a String object as an argument and displays its contents backward. For instance, if the string argument is “gravity” the method should display -“ytivarg”. Demonstrate the method in a program that asks the user to input a string and then passes it to the method. 3. Write a method called “wordCount()” that accepts a String object as an argument and returns the number of words it contains. In this case, we will assume blank spaces separate words. For instance, if the argument is “Four score and seven years ago” the method should return the number 6. Demonstrate the method in a program that asks the user to input a string and then passes it to the method. The number of words in the string should be displayed on the screen. (Hint: the split() String method could be useful.)

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.