zoukankan      html  css  js  c++  java
  • 第五周课程总结与报告

    实验三 String类的应用
    •实验目的
    •掌握类String类的使用;
    •学会使用JDK帮助文档;
    •实验内容

    1.已知字符串:"this is a test of java".按要求执行以下操作:(要求源代码、结果截图。)
    •统计该字符串中字母s出现的次数。
    •统计该字符串中子串“is”出现的次数。
    •统计该字符串中单词“is”出现的次数。
    •实现该字符串的倒序输出。

    2.请编写一个程序,使用下述算法加密或解密用户输入的英文字串。要求源代码、结果截图。

    3.已知字符串“ddejidsEFALDFfnef2357 3ed”。输出字符串里的大写字母数,小写英文字母数,非英文字母数。

    一.实验代码

    package Fuck;
    
    public class Fuck {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
             String s = "this is a test of java";
             int n = (s.split("s")).length - 1;
             System.out.println("s出现的次数" + n);
             
             int t = (s.split("is")).length - 1;
             System.out.println("is出现的次数" + t);
             
             int g = (s.split(" is ")).length - 1;
             System.out.println(" is 出现的次数" + g);
             
             StringBuffer str = new StringBuffer(s);
             str = str.reverse();
             System.out.println(str);
        }
    }
    

    (1)实验结果

    二.实验代码

    public class RNG {
    
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		System.out.println(" 加密还是解密 ?");
            Scanner input=new Scanner(System.in);
            int x;
            if(input.nextLine().equals("解密")){
               x=0;
               }
            else {
               x=1;
            }
            String s=input.nextLine();
            char[] ch=s.toCharArray();
            if(x==1) {
                for(int i=0;i<ch.length;i++){
                   ch[i]=(char)(ch[i]+3);
            }
            }else {
                for(int i=0;i<ch.length;i++){
                    ch[i]=(char)(ch[i]-3);
                }
             }
            s=s.valueOf(ch);
            System.out.println(s);
    
    
    	}
    
    }
    

    运行截图

    三,实验代码

    public class FUCK1 {
    
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		 public static void main(String[] args) {
    		        // TODO Auto-generated method stub
    		        String s="ddejidsEFALDFfnef2357 3ed";
    		        char[]ch=s.toCharArray();
    		        int sd=0,sx=0,sf=0;
    		        for(int i=0;i<ch.length;i++) {
    		            if(ch[i]>='A'&&ch[i]<='Z') {
    		                sd++;
    		            }
    		            else if(ch[i]>='a'&&ch[i]<='z'){
    		                sx++;
    		            }
    		            else {
    		                sf++;
    		            }
    		        }
    		        System.out.println(sd);
    		        System.out.println(sx);
    		        System.out.println(sf);
    
    
    	}
    
    }
    

    运行截图

    总结:
    好嗨哦,感觉人生已经到达了高潮,感觉人生已经到达了巅峰。

  • 相关阅读:
    cisco telnet(转载)
    华为bfd配置步骤
    cisco ssh实验--附带配置脚本-2019.11.19
    远程设备管理opendx平台搭建-server,agent以及front实际搭建
    远程设备管理opendx平台搭建-appium和adb的安装
    华为交换机sflow配置
    华为交换机netstream配置
    centos6虚拟机复制后修改网卡
    docker基本操作
    esxi 6 添加硬盘、网卡
  • 原文地址:https://www.cnblogs.com/dxl1314520/p/11600152.html
Copyright © 2011-2022 走看看