从用户那里获取输入 [英] getting input from user

查看:64
本文介绍了从用户那里获取输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的先生,

我想从用户那里获取任何三个数字,并找到输入的最大数字.

Dear sir,

I would like to get any three numbers from the user and find maximum number entered.

推荐答案

开始 ^ ].


这可能会帮助您:::

导入java.io. *;
Class Max
{
公共静态void main(String str [])
{
int a,b,c,max;
试试
{
扫描仪秒=新的扫描仪(System.in);
System.out.println(输入您的第一个数字:");
a = sec.nextInt();
System.out.println(输入您的次编号:");
b = sec.nextInt();
System.out.println(输入您的第一个数字:");
a = sec.nextInt();
System.out.println(输入您的第三个数字:");
c = sec.nextInt();
max = a;
if(b> max)
max = b;
if(c&max; max)
max = c;
System.out.println(更大的数字是" + max);
}
赶上
{
System.out.println(发现错误");
}

}

}
This may help you out:::

import java.io.*;
Class Max
{
public static void main(String str[])
{
int a,b,c,max;
try
{
Scanner sec= new Scanner(System.in);
System.out.println("Enter your First num:");
a= sec.nextInt();
System.out.println("Enter your Secound num:");
b= sec.nextInt();
System.out.println("Enter your First num:");
a= sec.nextInt();
System.out.println("Enter your Third num:");
c=sec.nextInt();
max=a;
if(b>max)
max=b;
if(c>max)
max=c;
System.out.println("The greater number is "+max);
}
catch
{
System.out.println("Error found");
}

}

}


这篇关于从用户那里获取输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆