// daypr.java // daily production and consumption // adapted from a program in basic by H.T. Odum & E. Odum, 1994 import java.applet.*; import java.awt.*; public class daypr extends Applet { Label prompt1, prompt2; TextField input1, input2; Button drawbutton; double TN, K, K1, K2, K3, t, ti, Q, Qi, J, Ji, N, Ni, DQ, JR; public void init() { prompt1 = new Label("TN Total available nutrients: "); input1 = new TextField("10", 5); add(prompt1); add(input1); prompt2 = new Label("K2 Decreasing coefficient: "); input2 = new TextField("4", 3); add(prompt2); add(input2); drawbutton = new Button("Draw"); add(drawbutton); } public boolean action(Event e, Object o) { TN = (float)Integer.parseInt(input1.getText()); K2 = (float)Integer.parseInt(input2.getText()); repaint(); return true; } public void paint(Graphics g) { g.drawRect(0,60,320,250); t=0; Q=5; J=0; TN=TN/10; K=0.9; K1=0.2; K2=K2/100; K3=0.01f; N=TN-K3*Q; g.drawLine(0,200,320,200); while (t<320) { ti=t+1; Ji=40*Math.sin(ti/15.9); if(Ji<0)Ji=0; JR=J/(1+K*N); DQ=K1*JR*N-K2*Q; Qi=Q+DQ; Ni=TN-K3*Qi; g.setColor(Color.blue); g.drawLine((int)t, (int)(200-0.5*Q), (int)ti, (int)(200-0.5*Qi)); g.setColor(Color.green); g.drawLine((int)t, (int)(310-50*N), (int)ti, (int)(310-50*Ni)); g.setColor(Color.red); g.drawLine((int)t, (int)(120-J), (int)ti, (int)(120-Ji)); N=Ni; Q=Qi; J=Ji; t=ti; } } } // Manuel Basler & E. Ortega, October 6th 2000*/