Fifth week of the third week of the experimental study summary and report

1. Known string: "this is a test of java" required to do the following requirements :( source code, the results screenshot).

The number of letters in the string s appears ① statistics.
A: experiment code several run shot

The number of neutrons ② string string "is" appears in the statistics.

The number of words in the string "is" appears ③ statistics.

④ achieve reverse the string is output.

I do not know in the end that I want to capture all the oh

2. Write a program, using the following algorithm to encrypt or decrypt the English string input by the user. It requires source code, the results screenshot.
Experiment code:

import java .util.Scanner;
public class Demo1 {

    public static void main(String[] args) {
        System.out.println("加密还是解密?");
        Scanner input=new Scanner(System.in);
        int n;
        if(input.nextLine().equals("解密"))
        {
            n=0;
        }
        else
        {
            n=1;
        }
        String str=input.nextLine();
        char[] c=str.toCharArray();
        if(n==1)
        {
            for(int i=0;i<c.length;i++)
            {
                c[i]=(char) (c[i]+3);
            }
        }
        else {
            for(int i=0;i<c.length;i++)
            {
                c[i]=(char)(c[i+3]);
            }
        }
        str=str.valueOf(c);
        System.out.println(str);
    }
}

Two: Run Screenshot



3. Given the string "ddejidsEFALDFfnef2357 3ed". The output string in the number of capital letters, lowercase letters count, the number of non-English letters.
A: experiment code

package test;

public class Demo1 {

    public static void main(String[] args) {
        String str="ddejidsEFALDFfnef2357 3ed";
        int m=0,n=0,k=0;
        char[] c=str.toCharArray();
        for(int i=0;i<str.length();i++)
        {
            if(c[i]>='a'&&c[i]<='z')
            {
                m++;
            }
            else if(c[i]>='A'&&c[i]<='Z')
            {
                n++;
            }
            
            else {
                k++;
            }
        }
        System.out.println("小写字母出现的次数:"+m);
        System.out.println("大写字母出现的次数:"+n);
        System.out.println("其他字符出现的字数:"+k);
        
    }

}

Two: Run Screenshot

summarize

1: In this week I carefully read the entire contents of the String class, learned a lot, made a bold dare to subject, to understand their basic operating procedures.
2: In the classroom preliminary understanding with super This two key words to use and where the difference, but still a little but still have their own serious reading, ha ha ha.
3: For a preliminary understanding of inheritance, the subclass calls for precautions and methods of the parent class constructor. (I.e. extension of the method of the parent class (attribute) or configuration)
4: for understanding polymorphic class Object, child and parent class transition, i.e. subclass can automatically be converted to the parent, the parent does not automatically become the subclasses must Transformation by forcing.
5 :: abstract class for understanding, really good abstract !!!!!
concluded still have to spend a lot of time on learning materials, although there is a little known, then the class is to learn something in the classroom? ? ?

Maybe it like him, only you know you re going to someone else to help you, others do not know what you want, and read a book or your own understanding of it! ! ! !

Guess you like

Origin www.cnblogs.com/chenxinxin/p/11595347.html