第一次过程性考核

  第一次过程性考核
码云主页:https://gitee.com/liyouyoua/codes 

7-1:要求输出Hello world!
码云地址: <script src='https://gitee.com/liyouyoua/codes/yt08bhu9kslnf56a2ezdw18/widget_preview?title=gistfile1.java 

'></script>
设计思路:直接输出System.out.println(Hello world!);
运用的知识点:System.out.println
运用代码:
public class Main {
public static void main  (String args[]) {
System.out.println("Hello World!");
}
}
运行结果:

 

 


 
7-2求1到100的和
本题要求编写程序,计算表达式 1 + 2 + 3 + ... + 100 的值
码云地址:<script src='https://gitee.com/liyouyoua/codes/q01ic6twjhkxzngl2dve788/widget_preview?title=gistfile1.java 

'></script>
程序的设计思路:定义整型变量i sum,
初始化语句,
循环条件i<=100,当i<=100时sum=sum+i i++,当i>100时循环结束并输出结果
使用到的知识点:输出基本型数据 System.out.println(),自增运算符i++,While循环语句
运行结果:

 



 
7-3:计算居民水费
为鼓励居民节约用水,自来水公司采取按用水量阶梯式计价的办法
码云地址:<script src='https://gitee.com/liyouyoua/codes/9ud4k36ar2tswgyj18lpv73/widget_preview?title=gistfile1.java 

'></script>
设计思路:运用输入输出语句;因为不同的收费标准,所以运用if   else 判断语句。
运用知识点:if()else();print;%.2f
运用代码:
import java.util.Scanner;
public class Main {
  public static void main (String args[]){
    Scanner scan =new Scanner(System.in 

);
    double y;
    double x =scan.nextDouble();
    if(x>=0 && x<=15) {
      y = 4 * x / 3;
    }
    else {
      y = 2.5 * x - 17.5;
    }
  System.out.printf("%.2f",y);
  }
}

 
运行结果:  

 

 

7-4:打印九九乘法表
码云地址:<script src='https://gitee.com/liyouyoua/codes/ls7n5mp1y3acx6rojdzq830/widget_preview?title=gistfile1.java 

'></script>
设计思路:运用了for循环,判断前面的数j是否小于等于后面的i,不是就进行下一次一循环;要求等号后面占四位,%-4d。        
运用知识点:for循环;i++;%-4d
运行代码:
import java.util.Scanner;
public class Main {
  public static void main (String args[]){
    Scanner cin = new Scanner(System.in 

);  
    int n = cin.nextInt();
    for(int i = 1;i <= n;i++){
      for(int j = 1; j <= i; j++){
        if (j == i) {
          System.out.printf("%d*%d=%-4d\n", j, i,i * j);
        }
        else{
          System.out.printf("%d*%d=%-4d", j, i,i * j);
        }
      }
    }
  }
}
运行结果:

 

posted @ 2018-09-16 11:24  李又又  阅读(313)  评论(1编辑  收藏  举报