java三元運算符 java定義3個整數(shù),輸出這3個整數(shù)的平均值?
java定義3個整數(shù),輸出這3個整數(shù)的平均值?java義3個25972; 25968;,輸java.util.Scanner文件public class MyDao{public static voi
java定義3個整數(shù),輸出這3個整數(shù)的平均值?
java義3個25972; 25968;,輸java.util.Scanner文件
public class MyDao{
public static void main(String args[]){
Scanner sc=new Scanner(程序輸入)
系統(tǒng)輸出打?。ā?”“1”“1”“1””)a=sc.nextInt公司()
系統(tǒng)輸出打印(“2”“2”“2”“2””)=sc.nextInt公司()
系統(tǒng)輸出打?。ā罢堓?shù)?個數(shù):”)=sc.nextInt公司()
系統(tǒng)輸出打印導(dǎo)入java.util.Scanner文件
公共類TestIncreace{
void TestInc(int n)拋出異常{
int[]a=new int[n
]int sum=0
對于(int i=0i< a.lengthi){
a[i]=n%10
n=n/10
sum=a[i
]}系統(tǒng)輸出打?。╯um)
}
public static void main(String[]args)引發(fā)異常{
try{
TestIncreace t=newTestIncreace()系統(tǒng)輸出打?。ā皰呙杵鬏斎?新掃描器(程序輸入)
輸入=輸入.nextInt()
t.TestInc(in)//捕獲(異常e){系統(tǒng)輸出打印("非法數(shù)字")
}
}
}