close

/* 輸入兩個整數, 計算其合, 差, 乘積.
輸入國文, 英文和數學成績, 計算其總分數及每科平均成績*/

import java.io.*;
import java.util.Scanner;

public class Main {
public static void main(String args[]) throws IOException{

String text,text1,text2,text3,text4;
Scanner scanner = new Scanner(System.in);
System.out.print("請輸入第一個整數: ");
text = scanner.next();
System.out.print("請輸入第二個整數: ");
text1 = scanner.next();
System.out.print("請輸入國文: ");
text2 = scanner.next();
System.out.print("請輸入英文: ");
text3 = scanner.next();
System.out.print("請輸入數學: ");
text4 = scanner.next();



int i= Integer.parseInt(text);
int j= Integer.parseInt(text1);

int y= Integer.parseInt(text2);
int x= Integer.parseInt(text3);
int h= Integer.parseInt(text4);


System.out.println("其合:"+(i+j));
System.out.println("差:"+(i-j));
System.out.println("乘積:"+(i*j));
System.out.println("總分數:"+(y+x+h));
System.out.println("每科平均成績:"+((y+x+h)/3));
}
}

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 萌新-工程師 的頭像
    萌新-工程師

    工程師的雜記

    萌新-工程師 發表在 痞客邦 留言(0) 人氣()