================file: Dist.java============================ /* class Dist generic distribution function. alt="Your browser understands the <APPLET> tag but isn't running the applet, for some reason." Your browser is completely ignoring the <APPLET> tag! */ public class Dist { public static double hw=1.0;// measure energy in hw. public static double kt=25.0;// temperature public static double n = 20000; //number of atoms double clow = 2.; double chigh = 2.; double c = 2.; int max_e =0; int max_n =0; void findc(){ c=2; while(sum()>n){c*=2;} chigh=c; while(sum()0.0001*n){ if(sum()>n) clow=c; else chigh=c; c=(chigh+clow)/2.0; } } double f(int i) { return g(i)/(c*Math.exp(hw*i/kt)-1.); } double sum(){ int summ=300;//include 300 terms double sum; double maxn=0.0; sum=0.0; for(int i=0;imaxn){ maxn=fv; max_n=(int)(fv+.5); max_e=i; } sum = sum+fv; } return sum; } static double g(int i){ return (i+2.)*(i+1.)/2.; } } ================file: FDDist.java============================ /* class Dist generic distribution function. alt="Your browser understands the <APPLET> tag but isn't running the applet, for some reason." Your browser is completely ignoring the <APPLET> tag! */ public class FDDist extends Dist { double f(int i) { return g(i)/(c*Math.exp(hw*i/kt)+1.0); } } ================file: G3.java============================ /* graph BEdist alt="Your browser understands the <APPLET> tag but isn't running the applet, for some reason." Your browser is completely ignoring the <APPLET> tag! */ import java.awt.Graphics; import java.awt.*; public class G3 extends java.applet.Applet { int scrollint=0; int scrollintold=0; G3 myapp = this; Timer1 timer= new Timer1(this); Dist be = new Dist(); MBDist mb = new MBDist(); FDDist fd = new FDDist(); Scrollbar s = new Scrollbar(Scrollbar.HORIZONTAL,250,10,1,500); public void init() { Choice c; setLayout(new BorderLayout() ); Panel p = new Panel(); p.setLayout(new BorderLayout() ); p.add("North",s); Panel p1 = new Panel(); p1.add(new Label("M =")); p1.add(c=new Choice()); c.addItem("10000"); c.addItem("5000"); c.addItem("1000"); c.addItem("500"); c.addItem("100"); c.addItem("50"); c.addItem("10"); p.add("South",p1); add("North",p); timer.start(); } public boolean action(Event evt,Object arg){ if (evt.target instanceof Choice) { be.n = Integer.parseInt(arg.toString()); myapp.repaint(); } return true; } public void step() { scrollintold=scrollint; scrollint=s.getValue(); if(scrollint != scrollintold) { be.kt=scrollint/10.0; repaint(); } } public void paint(Graphics g) { be.findc(); mb.findc(); mb.sum(); fd.findc(); int left=10; int right=size().width-10; int top=40; int bottom=size().height-10; int b2=(bottom-top)*2/3+top; int b3=(bottom-top)/3+top; System.out.println("painting with kt "+be.kt); g.setColor(Color.red); g.drawString("Bose-Einstein",right-150,top+30); g.drawString("kT = "+be.kt,right-150,top+40); g.drawString("Emax, N = "+be.max_e+", "+be.max_n,right-150,top+50); g.setColor(Color.blue); g.drawString("Maxwell Boltzman",right-150,b3+30); g.drawString("kT = "+mb.kt,right-150,b3+40); g.drawString("Emax, N = "+mb.max_e+", "+mb.max_n,right-150,b3+50); g.setColor(Color.black); g.drawString("Fermi Dirac",right-150,b2+30); g.drawString("kT = "+fd.kt,right-150,b2+40); g.drawString("Emax, N = "+fd.max_e+", "+fd.max_n,right-150,b2+50); for (int x =left ; x < 300+left ; x++) { g.setColor(Color.red); g.drawLine(2*x,b3,2*x, b3-(int)(be.f(x-left)+.5)); g.drawLine(2*x,b3-(int)(be.f(x-left)+.5),2*x+1, b3-(int)(be.f(x-left)+.5)); g.setColor(Color.blue); g.drawLine(2*x,b2,2*x, b2-(int)(mb.f(x-left)+.5)); g.drawLine(2*x,b2-(int)(mb.f(x-left)+.5),2*x+1, b2-(int)(mb.f(x-left)+.5)); g.setColor(Color.black); g.drawLine(2*x,bottom,2*x, bottom-(int)(fd.f(x-left)+.5)); g.drawLine(2*x,bottom-(int)(fd.f(x-left)+.5),2*x+1, bottom-(int)(fd.f(x-left)+.5)); } } public String getAppletInfo() { return "Draws a Distribution graph."; } } class Timer1 extends Thread { G3 myapplet; public Timer1(G3 myapplet){ this.myapplet=myapplet ; setPriority(MIN_PRIORITY); } public void run() { for(;;){ myapplet.step(); yield(); try{sleep(1000L);} catch(InterruptedException e){;} } } } ================file: MBDist.java============================ /* class Dist generic distribution function. alt="Your browser understands the <APPLET> tag but isn't running the applet, for some reason." Your browser is completely ignoring the <APPLET> tag! */ public class MBDist extends Dist { void findc(){ c=1.0; c=sum()/n; } double f(int i) { return g(i)/(c*Math.exp(hw*i/kt)); } }