import java.util.Scanner
public class Program1 {
public static void main(String[] args) {
Scanner i = new Scanner(System.in)
int a = i.nextInt()
int b = i.nextInt()
if (a >100 || a <10 || b>100 ||b<10) {
System.out.println("输入错误,请输入两位数!")
}else{
System.out.println(a + b)
}
}
}
扩展资料:java的用法小结
一、简单的stream,parallelStream慎用
List<Integer>list = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8)
list.parallelStream().forEach(System.out::println)
list.parallelStream().forEachOrdered(System.out::println)
二、简单的stream, collect, sum, count,
1、取某一字段 stream &collect
System.out.println(userList.stream().map(User::getAddress).collect(Collectors.toList()))
System.out.println("---------")
ArrayList<String>arrayList =
userList.stream().map(User::getAddress).collect(Collectors.toCollection(ArrayList::new))
System.out.println(arrayList)
System.out.println("---------")
System.out.println(userList.stream().map(User::getAddress).collect(Collectors.joining("@@")))
2、取总和 sum
System.out.println(userList.stream().mapToInt(User::getAge).sum())
3、分组
Map<String, List<User>>addressMap =
userList.stream().collect(Collectors.groupingBy(User::getAddress))
System.out.println(addressMap)
不知道楼主想要的具体是什么。。。。这是个输入任意两个实数然后输出结果的程序,希望对楼主有帮助。。。import java.io.*class Additional{
public static void main(String args[]){
double a
double b
System.out.println("请输入第一个加数(按回车结束):")
try {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in))// 读入第一个输入的值
a = Double.parseDouble(in.readLine())
System.out.println("请输入第二个加数(按回车结束):") //读入第二个输入的值
b = Double.parseDouble(in.readLine())
System.out.println("运算结果是:\n"+a+"+"+b+"="+(a+b))
} catch (IOException e){
e.printStackTrace()
}
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)