随机输入两个数,求两个输入数的和,用JAVA怎麽写
- 提问者网友:愿为果
- 2021-06-01 18:59
- 五星知识达人网友:忘川信使
- 2021-06-01 19:31
您好,很高兴为你解答:
============================================================
import java.util.*;
public class Sum
{
public static void main(String [] args)
{
Scanner input1=new Scanner(System.in);
Scanner input2=new Scanner(System.in);
int sum=0;
int a=input1.nextInt();
int b=input2.nextInt();
sum=a+b;
System.out.println(a+"和"+b+"两数的和是"+sum);
}
}
- 1楼网友:空山清雨
- 2021-06-01 23:53
import java.uill.Scanner;
public class a
{
public static void main (String args [])
{
Scanner input = new Scanner (System.in);
double a= input.nextdouble();
double b= input.nextdouble();
double c = a+ b;
System.out.println (a+"+"+b+"="c);
}
}
如果你想了解更多,推荐:www.tsp2c.cn
- 2楼网友:封刀令
- 2021-06-01 22:40
这个是online judge第一题吧
import java.lang;
public class test
{
public static void main(String [] args)
{
while( int a, int b ){
return a +b ;
}
}
- 3楼网友:末日狂欢
- 2021-06-01 21:14
import java.util.Scanner;
public class Junye{
public static void main(String [] args){
Scanner input1=new Scanner(System.in);
Scanner input2=new Scanner(System.in);
int sum=0;
int a=input1.nextInt();
int b=input2.nextInt();
sum=a+b;
System.out.println(a+"和"+b+"两数的和是"+sum);
}
}
- 4楼网友:舊物识亽
- 2021-06-01 20:36
import java.uill.Scanner;
public class a
{
public static void main (String args [])
{
Scanner input = new Scanner (System.in);
double a= input.nextdouble();
double b= input.nextdouble();
double c = a+ b;
System.out.println (a+"+"+b+"="c);
}
}
你可以先找一本java书看看,像这种题在初级java书里都应该有例题的。
- 5楼网友:举杯邀酒敬孤独
- 2021-06-01 20:24
public int sum(int A,int B)
{
return A+B;
}