// macroec.java // textbook macroeconomics // adapted from a program in basic by H.T. Odum & E. Odum, 1994 import java.applet.Applet; import java.awt.*; public class macroec extends Applet { Label prompt1,prompt2,prompt3; TextField input1,input2,input3; double E,k2,k5; Button drawbutton; public void init() { prompt1 = new Label("E Energy source: "); input1 = new TextField("2",4); add(prompt1);add(input1); prompt2 = new Label("K2 Depreciation rate of the growing assets: "); input2 = new TextField("45",4); add(prompt2);add(input2); prompt3 = new Label("K5 percent of income saved and reinvested: "); input3 = new TextField("10",4); add(prompt3);add(input3); drawbutton = new Button("Draw"); add(drawbutton); } public boolean action(Event e, Object o) { E=(float)Integer.parseInt(input1.getText()); k2=0.01*(float)Integer.parseInt(input2.getText()); k5=0.1*(float)Integer.parseInt(input3.getText()); repaint(); return true; } public void paint(Graphics g) { g.drawRect(0,90,320,210); int t; double x,kz,j,y,s,i,c,k,pr,r; double dt,dk,t0,y0; double k0,k1,k3,k4,k6; x=0; t=0; dk=0; kz=3; j=100; y=10; s=kz*y; i=s; c=y-s;k=10; dt=0.1; t0=10; y0=3; k0=0.1; k1=1; k3=1; k4=0.011; k6=0.00011; do { if (y*y0>180) g.setColor(Color.blue); g.drawOval(t,(int)(300-y*y0),1,1); if (k*kz>180) g.setColor(Color.red); g.drawOval(t,(int)(300-k*kz),1,1); if (x==0) { dk=k3*i-k6*E*c*k-k2*k; pr=k4*c*k*E;// duvida } else { r=j/(1+k0*k*c);//duvida pr=k4*c*k*r; y=k1*pr; s=k5*y; i=s; c=y-s; } k=k+dk*dt; // duvida if (k<0.00001) k=0.00001; t=t+1; } while(t<=320); } } // Camila Duarte & E. Ortega, January 30th, 2001