标签:
代码为:package com.lwk.test2;
主类:
import java.util.Scanner;
package com.lwk.test2;
public class Demo {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Test test = new Test();
test.test();
}
}
方法类:
package com.lwk.test2;
import java.util.Scanner;
public class Test2{
public void test() {
Scanner input = new Scanner(System.in);
System.out.print("请输入x:");
double x = input.nextDouble();
System.out.print("请输入Y:");
double y = input.nextDouble();
if (x < 4 || y > 0) {
if (y > 1) {
y = y + 1;
System.out.println("此时x=:"+x+"y=:"+y);
System.out.println("结束");
} else {
System.out.println("此时x=:"+x+"y=:"+y);
System.out.println("结束");
}
} else {
if (x >= 5) {
x = x - y;
System.out.println("此时x=:"+x+"y=:"+y);
System.out.println("结束");
} else {
x = x + y;
System.out.println("此时x=:"+x+"y=:"+y);
System.out.println("结束");
}
}
}
}
? 按照所给的程序流程图,写出Java代码(用类和方法实现)
标签:
原文地址:http://www.cnblogs.com/lwkblog/p/5367870.html