6个回答
展开全部
import java.util.Scanner;
public class C {
public static void main(String[] args) {
int x;
int y=0;
System.out.println("请输销郑入孙肆X的值"则斗轿);
Scanner q = new Scanner(System.in);
x = q.nextInt();
if (x > 0)
{
y= x + 2;
}
else if (x == 0)
{
y= x - 2;
}
else if (x < 0)
{
y= x - 4;
}
System.out.println("y="+y);
}
}
public class C {
public static void main(String[] args) {
int x;
int y=0;
System.out.println("请输销郑入孙肆X的值"则斗轿);
Scanner q = new Scanner(System.in);
x = q.nextInt();
if (x > 0)
{
y= x + 2;
}
else if (x == 0)
{
y= x - 2;
}
else if (x < 0)
{
y= x - 4;
}
System.out.println("y="+y);
}
}
展开全部
public static void main(String[] args) {
try{
Scanner sc = new Scanner(System.in);
System.out.print("吵森裂请输入X的值: ");
int x = sc.nextInt();
int value = getY(x);
System.out.println("y = "升闭春衡 + value);
}catch(Exception e){
System.out.println("请输入数字");
}
}
private static int getY(int x) {
int value = 0;
if(x > 0){
value = x + 2;
}else if(x < 0){
value = x - 4;
}else{
value = x - 2;
}
return value;
}
try{
Scanner sc = new Scanner(System.in);
System.out.print("吵森裂请输入X的值: ");
int x = sc.nextInt();
int value = getY(x);
System.out.println("y = "升闭春衡 + value);
}catch(Exception e){
System.out.println("请输入数字");
}
}
private static int getY(int x) {
int value = 0;
if(x > 0){
value = x + 2;
}else if(x < 0){
value = x - 4;
}else{
value = x - 2;
}
return value;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Scanner sc=new Scanner(System.in);
System.out.println("山枝请慎哗输入x的逗孝敏值");
int x=sc.nextInt();
int y=0;
if(x>0){
y=x+2;
}else if(x==0){
y=x-2;
}else{
y=x-4;
}
System.out.println(y);
System.out.println("山枝请慎哗输入x的逗孝敏值");
int x=sc.nextInt();
int y=0;
if(x>0){
y=x+2;
}else if(x==0){
y=x-2;
}else{
y=x-4;
}
System.out.println(y);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Test t = new Test();
t.test();
}
public void test() {
System.out.println("知困宽请搭亮出入x的值:");
Scanner input = new Scanner(System.in);
int x = input.nextInt();
if (x >尺山 0) {
x += 2;
} else if (x == 0) {
x -= 2;
} else {
x -= 4;
}
int y = x;
System.out.println(y);
}
}
public class Test {
public static void main(String[] args) {
Test t = new Test();
t.test();
}
public void test() {
System.out.println("知困宽请搭亮出入x的值:");
Scanner input = new Scanner(System.in);
int x = input.nextInt();
if (x >尺山 0) {
x += 2;
} else if (x == 0) {
x -= 2;
} else {
x -= 4;
}
int y = x;
System.out.println(y);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-09-29
展开全部
if(x>0) 缓态Y=x+2;
else if(x<0) Y=x-4;
else Y=x-2; // x=0
System.our.println("Y="扰首源芹迟+Y);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
public int getY(int x)
{
if (x > 0)
{
return x + 2;
}
else if (x == 0)
{
return x - 2;
}
else if (x < 0)
{
return x - 4;
}
return 0;
}
{
if (x > 0)
{
return x + 2;
}
else if (x == 0)
{
return x - 2;
}
else if (x < 0)
{
return x - 4;
}
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询