1,String processing problems
Problem description: cyclically receives a string greater than 3 from the keyboard and can be input cyclically. Complete the following functions:
(1) Length of the output string.
(2) the first occurrence of the letter a in the output string.
(3) number of times the substring AB appears in the output string.
(4) After the string contains 3rd characters, insert the string "C #" and output the new string.
(5) Replace "C #" in the string with "Java" and output the new string.
(6) use the character "c" as the separator to split the string and output the separated string.
Test example:
Input example: AB
Output example: Enter at least 3 Characters
Input example: 123abcabc123
Output example: the string length is 12.
The first occurrence of letter a is 3
The substring AB appears twice.
The new string after insertion is 123C # abcabc123
The new string after replacement is 123Javaabcabc123.
The split string using c is:
123 Javaab
AB
123
2. Classes and objects
A parent class:
Age and name (attribute)
Method with return value: speak ()
Two methods without return values: one has a parameter, the other has no parameters, and both methods are sing;
A method without return values: There are two parameters: age and name. The method is Info ();
One child subclass: inherits the parent class
Override the father's Info () method
Write Other content as needed
A daughter class: inherits the father class
There are two shopping methods: goShopping (), goShopping (string clothesName, double clothesPrice );
Override the father's Info ();
3. Date:
Input a date from the keyboard in the format of yyyy-mm-dd
Calculate the number of days between the date and January 1, October 1, 1949.
For example:
User entered: 1949-10-02
Program output: 1
User entered: 1949-11-01
Program output: 31