zoukankan      html  css  js  c++  java
  • 第五次上机

    package bwk2;
    public class Zye {
          public static void main(String[] args) {
                //假设某员工今年的年薪是30000元,年薪的年增长率6%。编写一个Java应用程序计算该员工10年后的年薪,并统计未来10年(从今年算起)总收入。(知识点:循环语句)
                int b,s,g,sum=0;
                for(int i=100;i<=999;i++) {
                     b=i/100;
                     s=i/10%10;
                     g=i%10;
                   sum=b*b*b+s*s*s+g*g*g;
                     if(sum==i) {
                        System.out.print(i+" ");
                }
                }
          }}

    package bwk2;
    
    public class Zye {
          public static void main(String[] args) {
                // 在控制台输出以下图形(知识点:循环语句、条件语句)
              for (int i = 1; i <=6; i++) {
                    for (int j = 1; j <= i; j++) {
                        System.out.print(j);
                    }
                    System.out.println("");
                }
                System.out.println("
    ");
                 
            for(int i=7;i>=1;i--){
                for(int j=1;j<=i-1;j++)
                    System.out.print(j);
            System.out.println();
         
                 
               
             
            }}
             
        }

    package bwk2;
    
    public class Zye {
          public static void main(String[] args) {
                // 在控制台输出以下图形(知识点:循环语句、条件语句)
              for(int i=1;i<7;i++) {
                  for(int j=i;j>0;j--) {
                      System.out.print(j);
                  }
                  System.out.println();
              }
            System.out .println("
    ");
            for(int i=6;i>0;i--) {
                  for(int k=0;k<6-i;k++) {
                      System.out.print(" ");
                  }
                  for(int j=1;j<=i;j++) {
                      System.out.print(j);
                  }
                  System.out.println("");
              }
      }
       
    }  

    package bwk2;
    import java.util.Scanner;
    public class Zye {
          public static void main(String[] args) {
                // 输入年月日,判断这是这一年中的第几天(知识点:循环语句、条件语句
              int sum = 0;
              Scanner sc = new Scanner(System.in) ;
              System.out.println("请输入年份:");
              int year = sc.nextInt();
              System.out.println("请输入月份:");
              int month = sc.nextInt();
              System.out.println("请输入日:");
              int day = sc.nextInt();
              for(int i =1 ; i<month;i++) {
              switch(i) {
              case 4:
              case 6:
              case 9:
              case 11:
                  sum +=30;
                  break;
              case 2:
                  if(year%4==0 && year %100!=0 || year %400 ==0) 
                      sum +=29;
                  else sum+=28;
                  break;
                  default:
                      sum +=31;
                      break;}
              }sum +=day;
              System.out.println("该天是第"+sum+"天");
              }
          } 

    package bwk2;
    import java.util.Scanner;
    public class Zye {
          public static void main(String[] args) {
                // 由控制台输入一个4位整数,求将该数反转以后的数,如原数为1234,反转后的数位4321(知识点:循环语句、条件语句)7
              Scanner sc = new Scanner(System.in);
              System.out.println("请输入一个四位数:");
              int i = sc.nextInt();
              int a = i/1000%10;
              int b = i/100%10;
              int c = i/10%10;
              int d = i%10;
              int reverse;
              reverse = d*1000+c*100+b*10+a;
              System.out.println("反转之后的数为:"+reverse);
              }
          }

  • 相关阅读:
    70.BOM
    69.捕获错误try catch
    68.键盘事件
    523. Continuous Subarray Sum
    901. Online Stock Span
    547. Friend Circles
    162. Find Peak Element
    1008. Construct Binary Search Tree from Preorder Traversal
    889. Construct Binary Tree from Preorder and Postorder Traversal
    106. Construct Binary Tree from Inorder and Postorder Traversal
  • 原文地址:https://www.cnblogs.com/bwk521/p/12619118.html
Copyright © 2011-2022 走看看