zoukankan      html  css  js  c++  java
  • 第一次java作业

    1.

    package test;

    public class demo{

           public static void main(String[] args) {

                  int a = 100;

                  int b = 200;

                  int tmp;

                  //进行数据交换

                  tmp = a;

                  a = b;

                  b = tmp;

                  System.out.println("交换后的a:"+ a + ",b:" + b);

    }

    }

    2.

    package test;

    import java.util.*;

    public class demo{

           public static void main(String[] args) {

                  //一个三位数整数,求各位整数的和

                  System.out.println("请输入一个1~1000的整数:");

                  Scanner sc = new Scanner(System.in);

                  int a = sc.nextInt();

                  int b, c, d, e, sum;

                  e = a / 1000;

                  b = a / 100 % 10;

                  c = a  / 10 % 10;

                  d = a % 10;

                  sum = b +c +d +e;

                  System.out.println("结果为" + sum);

           }

    }

    3.

    package test;

    import java.util.Scanner;

    public class demo{

           public static void main(String[] args) {

                  Scanner in = new Scanner(System.in);

                  int fatrenheit;//输入一个华氏温度

                  System.out.println("输入一个华氏度:");

                  fatrenheit=in.nextInt();

                  //转换为华氏温度

                  int celsius =(fatrenheit-32)*5/9;

                  //输出结果

                  System.out.println(fatrenheit+"华氏度是"+celsius+"摄氏度");

           }

          

    }

    4.

    package test;

    import java.util.*;

    public class demo{

           public static void main(String[] args) {

                  System.out.println("输入一个大写字母:");

                  Scanner sc = new  Scanner(System.in);

                  String c = sc.next();

                  char a = c.charAt(0);

                  System.out.println("小写字母为"+(char)(int)(a+32));

           } 

    }

  • 相关阅读:
    计算与软件工程作业一
    《CLSZS团队》:团队项目选题报告
    计算与软件工程第五次作业
    计算与软件工程第四次作业
    计算与软件工程代码规范
    计算与软件工程第三次作业
    计算与软件工程第二次作业
    壹贰叁肆团队项目选题报告
    计算与软件工程 作业五
    计算与软件工程 作业四
  • 原文地址:https://www.cnblogs.com/Zzzhqh/p/12523281.html
Copyright © 2011-2022 走看看