class Tgyl {
private int max=200;
int h=5;
public int gh(int x)
{if (x>=5*max) x=x-15; //供货商暂停采购
else //供货商请求采购
{if(x<20) x=x+20;
else x=x+20-15;
}return x;}
public int zz(int y)
{if (y>=max) y=y-2; //制造商暂停采购
else //制造商请求采购
{if(y<3) y=y+3;
else y=y+3-2;
}return y;}
}
class gyl{
public static void main(String[] args)
{int t1=210; //输入不同的t1值,则改变各个节点库存
int D=30; //输入不同的D值,产生不同的订单数量
System.out.println("on the "+t1+"th day,the order arrive and the volume is "+D);
int t2=1; //完成差异件需求所需要的时间
int t3;
int t4=0;
int p1=0; //供货商零部件库存
int p3=0; //制造商通用件库存
int p4=0; //分销商通用件库存
int p5=0; //订单成品完成量
int pp=0;
int p14=0; // 分销商差异件库存
int p=6; // 一件成品中包括6件通用件
int q=3; // 一件成品中包括3件差异件
Tgyl m = new Tgyl();
int t;
int T; //完成定单的全部响应时间
for (t=1;t<t1;t++){
if(t>=4){if (p4>=200)
break; //分销商暂停采购
else
p4=p4+2; //分销商请求采购
}
if(t>=3)
p3=m.zz(p3);
p1=m.gh(p1);}
if(p4>=200) p4=200;
while ((p3<200)&&(t<t1)&&(p4>=200))
{ p3=p3+3;
p1=m.gh(p1);
t++;}
if(p3>=200) p3=200;
while ((p1<200*5)&&(t<t1)&&(p4>=200)&&(p3>=200))
{ p1=p1+20;
t++;}
if(p1>=1000) p1=1000;
System.out.println("when order arrive,the volume of commonality: ");
System.out.println("the supplier reaches "+p1);
System.out.println("the manufacturer reaches "+p3);
System.out.println("the seller reaches "+p4);
int k=4; // 1件差异件=4件零部件
if (p1>=k*q*D) //开始差异件流程
{while(p14<q*D)
{if(t2>=3)
p14=3*(t2-2);
t2++;}}
else
{ int t21=1; //供货商补充零部件所需要的时间
int t22=1; //供货商补充后,分销商完成差异件需求所需要的时间
while(p1<k*q*D)
{ p1=p1+20;
t21++;}
while(p14<q*D)
{if(t22>=3)
p14=3*(t22-2);
t22++;}
t2=t21+t22;}
int c=5;//分销商每天组装5件成品
t3=D/5;
if (p4>=p*D)
{T=t1+t2+t3;}
else
{System.out.println("when orders are "+D+", in the volume of commonality ,the seller appears out of stock!");
while (pp<p*D-p4)
{ //完成订单剩余通用件需求
p1=m.gh(p1); //保证供货商零部件库存
p3=m.zz(p3); //保证制造商通用件库存
pp=pp+2;
t4++;}
T=t1+t2+t3+t4;}
System.out.println("when orders are finished,T="+T);}}
其中主函数里 t1 和 D 在程序运行时不能在键盘输入这两个参数的值 想改值的话只能是改源码里面的,再编译运行。我现在想在程序运行时接受键盘 参数输入,应该怎么做,谢谢各位老大。
private int max=200;
int h=5;
public int gh(int x)
{if (x>=5*max) x=x-15; //供货商暂停采购
else //供货商请求采购
{if(x<20) x=x+20;
else x=x+20-15;
}return x;}
public int zz(int y)
{if (y>=max) y=y-2; //制造商暂停采购
else //制造商请求采购
{if(y<3) y=y+3;
else y=y+3-2;
}return y;}
}
class gyl{
public static void main(String[] args)
{int t1=210; //输入不同的t1值,则改变各个节点库存
int D=30; //输入不同的D值,产生不同的订单数量
System.out.println("on the "+t1+"th day,the order arrive and the volume is "+D);
int t2=1; //完成差异件需求所需要的时间
int t3;
int t4=0;
int p1=0; //供货商零部件库存
int p3=0; //制造商通用件库存
int p4=0; //分销商通用件库存
int p5=0; //订单成品完成量
int pp=0;
int p14=0; // 分销商差异件库存
int p=6; // 一件成品中包括6件通用件
int q=3; // 一件成品中包括3件差异件
Tgyl m = new Tgyl();
int t;
int T; //完成定单的全部响应时间
for (t=1;t<t1;t++){
if(t>=4){if (p4>=200)
break; //分销商暂停采购
else
p4=p4+2; //分销商请求采购
}
if(t>=3)
p3=m.zz(p3);
p1=m.gh(p1);}
if(p4>=200) p4=200;
while ((p3<200)&&(t<t1)&&(p4>=200))
{ p3=p3+3;
p1=m.gh(p1);
t++;}
if(p3>=200) p3=200;
while ((p1<200*5)&&(t<t1)&&(p4>=200)&&(p3>=200))
{ p1=p1+20;
t++;}
if(p1>=1000) p1=1000;
System.out.println("when order arrive,the volume of commonality: ");
System.out.println("the supplier reaches "+p1);
System.out.println("the manufacturer reaches "+p3);
System.out.println("the seller reaches "+p4);
int k=4; // 1件差异件=4件零部件
if (p1>=k*q*D) //开始差异件流程
{while(p14<q*D)
{if(t2>=3)
p14=3*(t2-2);
t2++;}}
else
{ int t21=1; //供货商补充零部件所需要的时间
int t22=1; //供货商补充后,分销商完成差异件需求所需要的时间
while(p1<k*q*D)
{ p1=p1+20;
t21++;}
while(p14<q*D)
{if(t22>=3)
p14=3*(t22-2);
t22++;}
t2=t21+t22;}
int c=5;//分销商每天组装5件成品
t3=D/5;
if (p4>=p*D)
{T=t1+t2+t3;}
else
{System.out.println("when orders are "+D+", in the volume of commonality ,the seller appears out of stock!");
while (pp<p*D-p4)
{ //完成订单剩余通用件需求
p1=m.gh(p1); //保证供货商零部件库存
p3=m.zz(p3); //保证制造商通用件库存
pp=pp+2;
t4++;}
T=t1+t2+t3+t4;}
System.out.println("when orders are finished,T="+T);}}
其中主函数里 t1 和 D 在程序运行时不能在键盘输入这两个参数的值 想改值的话只能是改源码里面的,再编译运行。我现在想在程序运行时接受键盘 参数输入,应该怎么做,谢谢各位老大。
然后这样写
import java.unit.*
Scanner in=new Scanner(System.in);
int D=in.nextInt();
int t1=in.nextInt();
他是一个InputStream;
DataInputStream din =new DataInputStream(System.in);
String t1str= din.readline();
int t1= Integer.parseInt(t1str);