软件工程流程图程序演示
- 格式:doc
- 大小:67.00 KB
- 文档页数:3
public class TestSoftwareEngineeringWork {
public static void main(String[] args)
{
a;
do
{
b;
if (X1){
f;
if(X4){
do
{
i ;
}
while (X5);
}else{
g;
h;
}
}else{
switch(X2){
case 1:
do
{
c;
}
while (X3);
break;
case 2:
d;
break;
case 3:
e;
break;
default:
}
}
}
while (X6);
j;
}
}
/*在用java中用简单代码模拟该嵌套构成的流程实例图*/
import java.util.Scanner;
public class TestSoftwareEngineeringWork
{
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
System.out.println ("请输入1到10其中一个数字");
int a = s.nextInt(); //替代语句a
do
{
++a;
int b = a; //替代语句b
if (a < 5){ //模拟X1的判断,ture的执行X1右边代码块
int f = 4;//代替语句f
if(f < 5){//模拟X4的判断,ture执行X4右边代码块
boolean i = f >=20;
do
{
++f;
i = f >=20;//代替语句i;
}
while (false == i);//模拟X5的判断,但是java中没有do—until语句
//所以用do—while来解决,其中ture就执行i语句
}else{//相反false执行X4左边代码块
int g = a;//替代语句g
int h = a;//替代语句h
}
}else{ //相反false执行X1左边代码块
int X2 = a % 4;
switch(X2){
case 1:
do
{
++X2;//代替语句c
}
while (X2 < 5);//模拟X3的判断,false执行c语句,否则执行X6
break;
case 2:
int d = X2;//代替语句d
break;
case 3:
int e = X2;//代替语句e
break;
default:
}
}
}
while (a < 10);//替代X6的判断
System.out.println ("编译成功,语法无错");
}
}
编译运行后截图: