Java practical exercises: input student Wang Hao’s homework from the console and write a program to implement it. The difference in scores between Java class and SQL class. Average of three subjects

import java.util.Scanner;
public class Demo4 {
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        System.out.println("输入王浩的三门成绩");
        System.out.println("java:");
        int java = input.nextInt();
        System.out.println("ps");
        int ps = input.nextInt();
        System.out.println("sql");
        double sql = input.nextDouble();
        System.out.println("java和sql的差:" + (java - sql) );
        double mean = (java + sql + ps) / 3 ;
        System.out.println("平均值:"+ mean);
    }
 
}

/*

* - 1. Rule: If an operation type is double, the entire expression can be promoted to double

* - 2.int type and double type are compatible with each other, and the target type is larger than the source type. Such as: double type is greater than > int type

* */

Guess you like

Origin blog.csdn.net/m0_73358221/article/details/129376542