PDA

نسخه کامل مشاهده نسخه کامل : 1 برنامه ی جاوا



ronak_a22
27-02-2010, 13:24
سلام. لطفا کمکم کنید. برنامه ی زیر رو به جاوا میخوام.

__________________________________________________ _

Problem specification

Given a text containing sentences, you need to implement

the methods of class String, apply it on your string and

evaluate your methods by String methods.

The methods that you are going to implement is

substring(int,int), replace(char, char), replaceAll(char, char),

compareto(string), length().

You need to define an array of character at first and run

above methods on them. Then transform the array of char to

a String and apply the same methods that have been

provided by Java. The result should be the same.

You need to enter the String and ask the user which method

she is going to run. Depending on the method that user

chooses, you are required to ask related info. For example if

user chose compareto(string) you need to ask which string

should be compared with the original one.

Error conditions

Think of different possibilities that make the program

incorrect.

Hints

The java API is there to help you.

To create a string from your character array use

String(char[] value) method from String class.

Typical input

Input: A bad workman blames his tools.

1- substring(int,int)

2- replace(char,char)

3- replaceAll(char, char)

4- compareto(string)

5- length()

6- Exit.

Choose the method: 1

Begin: 6

End: 12

Corresponding output

The result is “workman”