[Java Grammar Basics] AcWing 608. Poor (Java Edition) Solution

table of Contents

1. Title

Read four integers A, B, C, D and calculate the value of (A * B-C * D).

Input format There are
four lines of input. The first line contains the integer A, the second line contains the integer B, the third line contains the integer C, and the fourth line contains the integer D.

Output format The
output format is "DIFERENCA = X", where X is the result of (A * B-C * D).

Data range
−10000≤A,B,C,D≤10000
Input example:
5 6 7 8
Output example:
DIFERENCA = -26

2. Code

import java.util.Scanner;
public class Main
{
    
    
    public static void main(String[] args)
    {
    
    
        Scanner sca=new Scanner(System.in);
        int a=sca.nextInt();  //读取a,b,c,d; 
        int b=sca.nextInt();
        int c=sca.nextInt();
        int d=sca.nextInt();
        int ans=a*b-c*d;
        System.out.println("DIFERENCA = "+ans);

    }
}


Guess you like

Origin blog.csdn.net/weixin_45629285/article/details/109344907