Hi, I've made a JApplet trying to simulate a macroeconomy. It works as I want it to when viewed in appletviewer, but when I view it from a browser, clicking Proceed after having changed values of JSliders in EconFinalM.class doesn't work.


EconFinal.java:

import java.awt.event.*; // Import Libraries.
import java.awt.*;
import java.applet.Applet;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
import java.util.*;

public class EconFinal extends JApplet{//Class extends JApplet.

	static Image l1;
	static Image objectiveimg;
	static Image procedureimg;
	static Image newsimg;
	static Image arrow1;
	static Image arrow2;
	static Image down;
	static Image up;
	static Image zero;
	static Image editimg;
	static Image win;
	static Image lose;
	static Color a=new Color(240,180,180);//colors for background
	static Color b=new Color(180,240,180);
	static Color c=new Color(200,200,240);
	static Color d=new Color(220,220,220);
	static Color e=new Color(240,200,170);
	static Color f=new Color(240,200,240);
	static Color g=new Color(180,240,240);
	static Color[] Pastel=new Color[]{a,b,c,d,e,f,g};//array
	static EconFinalC efc=new EconFinalC();//Instances?
	static EconFinalI efi=new EconFinalI();
	static EconFinalS efs=new EconFinalS();
	static EconFinalG efg=new EconFinalG();
	static EconFinalR efr=new EconFinalR();
	static EconFinalM efm=new EconFinalM();
	static EconFinalA efa=new EconFinalA();
	static EconFinalE efe=new EconFinalE();
	static CardLayout cl1=new CardLayout(40,40);
	
	static ArrayList<ControlEffect> ceal1=new ArrayList<ControlEffect>();
	static int gcounter = 0;
	static int govspend = 20;
	static int govspend1 = 20;
	static int govspend2 = 20;
	static int flattax = 15;
	static int flattax1 = 15;
	static int flattax2 = 15;
	static int openmkt = 0;
	static int openmkt1 = 0;
	static int openmkt2 = 0;
	static int discount = 3;
	static int discount1 = 3;
	static int discount2 = 3;
	static int reserve = 10;
	static int reserve1 = 10;
	static int reserve2 = 10;
	static String realgdps;
	static String inflations;
	static String interests;
	static String unemployments;
	static int yearcount=1;
	static int effective1=0;
	static int effective2=0;
	static double gov1=0.0;
	static double gov2=0.0;
	static double tax1=0.0;
	static double tax2=0.0;
	static double opo1=0.0;
	static double opo2=0.0;
	static double dcr1=0.0;
	static double dcr2=0.0;
	static double rsr1=0.0;
	static double rsr2=0.0;
	static double inf1=0.0;
	static double inflation=2.5;
	static double realgdp=15.0;
	static double rgdp=15.0;
	static double nominalgdp=0.0;
	static double interest=3.0;
	static double loans=0.0;
	static double unemployment=5.0;
	static boolean justclicked = true;
	static boolean justclicked1 = true;
	static boolean gsc = false;
	static boolean ftc = false;
	static boolean opc = false;
	static boolean drc = false;
	static boolean rrc = false;
	
	static boolean flood = false;
	static boolean crisis = false;
	static boolean recession = false;
	static boolean embargo = false;
	
	static boolean gameover = false;
	static boolean highinflation = false;
	static boolean highunemployment = false;
	static boolean gamewin = false;
	static boolean restart = false;
	
	static int floodyear = -3;
	static int crisisyear = -5;
	static int recessionyear = -3;
	static int embargoyear = -3;
	
	static int endyear = -1;


	public void init(){//init() goes here!
		endyear=efs.ageGenerator();
		efc.setLayout(cl1);
		efc.add(efs, "Start");	//Set up cardLayout in init().
		efc.add(efr, "Rules");//Add panels to container.
		efc.add(efi, "Initial");
		efc.add(efg, "Game");
		efc.add(efm, "Money");
		efc.add(efa, "Graphs");
		efc.add(efe, "End");
		getContentPane().add(efc);
		cl1.show(efc, "Start");//Show start first
		l1 = getImage(getCodeBase(),"Priceless.gif");//getImage()
		
		/*objectiveimg= getImage(getCodeBase(),"Objective.gif");
		procedureimg= getImage(getCodeBase(),"procedure.gif");
		newsimg= getImage(getCodeBase(), "News.gif");
		arrow1= getImage(getCodeBase(), "Arrowup.gif");
		arrow2= getImage(getCodeBase(), "Arrowdown.gif");
		down= getImage(getCodeBase(), "down.gif");
		up= getImage(getCodeBase(), "up.gif");
		zero= getImage(getCodeBase(), "zero.gif");
		editimg= getImage(getCodeBase(), "moveimg.gif");
		lose= getImage(getCodeBase(), "lose.gif");
		win= getImage(getCodeBase(), "win.gif");*/
	}



}

class EconFinalC extends JPanel implements ActionListener{//This class is the container panel for the CardLayout.
	//No variables needed in this class.
	EconFinalC(){//constructor.
	
	}
	public void paintComponent(Graphics g){//paintComponent().
	
	}
	public void actionPerformed(ActionEvent e){

	}
}

class EconFinalS extends JPanel implements ActionListener{//This class is the container panel for the CardLayout.
	//No variables needed in this class.
	EconFinal ef1=new EconFinal();
	EconFinalM efm=new EconFinalM();
	Font f1=new Font("Sans Serif",Font.PLAIN,14);
	Font f2=new Font("Sans Serif",Font.BOLD,36);	
	Color g1= ef1.Pastel[(int)Math.floor((Math.random()*7))];
	JButton jb1=new JButton("Rules");
	JButton jb2=new JButton("Start");
	EconFinalS(){//constructor.
		add(jb1);//button, addactionlistener, setBounds
		jb1.addActionListener(this);
		jb1.setBounds(200,320,95,30);
		add(jb2);//button, addactionlistener, setBounds
		jb2.addActionListener(this);
		jb2.setBounds(200,360,95,30);
		this.setLayout(null);

	}
	public void paintComponent(Graphics g){//paintComponent().
		if(EconFinal.gameover){
			EconFinal.ceal1.clear();
			EconFinal.gcounter = 0;
			EconFinal.govspend = 20;
			EconFinal.govspend1 = 20;
			EconFinal.govspend2 = 20;
			EconFinal.flattax = 15;
			EconFinal.flattax1 = 15;
			EconFinal.flattax2 = 15;
			EconFinal.openmkt = 0;
			EconFinal.openmkt1 = 0;
			EconFinal.openmkt2 = 0;
			EconFinal.discount = 3;
			EconFinal.discount1 = 3;
			EconFinal.discount2 = 3;
			EconFinal.reserve = 10;
			EconFinal.reserve1 = 10;
			EconFinal.reserve2 = 10;
			EconFinal.realgdps="";
			EconFinal.inflations="";
			EconFinal.interests="";
			EconFinal.unemployments="";
			EconFinal.yearcount=1;
			EconFinal.effective1=0;
			EconFinal.effective2=0;
			EconFinal.gov1=0.0;
			EconFinal.gov2=0.0;
			EconFinal.tax1=0.0;
			EconFinal.tax2=0.0;
			EconFinal.opo1=0.0;
			EconFinal.opo2=0.0;
			EconFinal.dcr1=0.0;
			EconFinal.dcr2=0.0;
			EconFinal.rsr1=0.0;
			EconFinal.rsr2=0.0;
			EconFinal.inf1=0.0;
			EconFinal.inflation=2.5;
			EconFinal.realgdp=15.0;
			EconFinal.rgdp=15.0;
			EconFinal.nominalgdp=0.0;
			EconFinal.interest=3.0;
			EconFinal.loans=0.0;
			EconFinal.unemployment=5.0;
			EconFinal.justclicked = true;
			EconFinal.justclicked1 = true;
			EconFinal.gsc = false;
			EconFinal.ftc = false;
			EconFinal.opc = false;
			EconFinal.drc = false;
			EconFinal.rrc = false;
			
			EconFinal.flood = false;
			EconFinal.crisis = false;
			EconFinal.recession = false;
			EconFinal.embargo = false;
			
			
			EconFinal.highinflation = false;
			EconFinal.highunemployment = false;
			EconFinal.gamewin = false;
			
			EconFinal.floodyear = -3;
			EconFinal.crisisyear = -5;
			EconFinal.recessionyear = -3;
			EconFinal.embargoyear = -3;
			
			EconFinal.endyear = -1;
			efm.js1.setValue(20);
			efm.js2.setValue(15);
			efm.js3.setValue(100);
			efm.js4.setValue(2);
			efm.js5.setValue(10);
			EconFinal.endyear=ageGenerator();
			EconFinal.gameover = false;
		}
		
		setBackground(g1);
		super.paintComponent(g);
		g.drawImage(ef1.l1,0,0,this);
		g.setFont(f1);
		g.setColor(Color.BLACK);
		g.drawString("GERMY LOO P5",180,410);
		g.drawString("AP Macroeconomics",170,430);
	}
	
	public static int ageGenerator(){
		double random=Math.random()*10-5.0;
		double num1=1.0;
		if(random<-4.998)
			num1=-3.8;
		else if(random>=-4.998&&random<-4.997)
			num1=-3.6;
		else if(random>=-4.997&&random<-4.993)
			num1=-3.2;
		else if(random>=-4.993&&random<-4.987)
			num1=-3.0;
		else if(random>=-4.987&&random<-4.974)
			num1=-2.8;
		else if(random>=-4.974&&random<-4.953)
			num1=-2.6;
		else if(random>=-4.953&&random<-4.918)
			num1=-2.4;
		else if(random>=-4.918&&random<-4.861)
			num1=-2.2;
		else if(random>=-4.861&&random<-4.772)
			num1=-2.0;
		else if(random>=-4.772&&random<-4.641)
			num1=-1.8;
		else if(random>=-4.641&&random<-4.452)
			num1=-1.6;
		else if(random>=-4.452&&random<-4.192)
			num1=-1.4;
		else if(random>=-4.192&&random<-3.849)
			num1=-1.2;
		else if(random>=-3.849&&random<-3.413)
			num1=-1.0;
		else if(random>=-3.413&&random<-2.881)
			num1=-0.8;
		else if(random>=-2.881&&random<-2.257)
			num1=-0.6;
		else if(random>=-2.257&&random<-1.554)
			num1=-0.4;
		else if(random>=-1.554&&random<-0.793)
			num1=-0.2;
		else if(random>=-0.793&&random<0)
			num1=0.0;
		else if(random>4.998)
			num1=3.8;
		else if(random<=4.998&&random>4.997)
			num1=3.6;
		else if(random<=4.997&&random>4.993)
			num1=3.2;
		else if(random<=4.993&&random>4.987)
			num1=3.0;
		else if(random<=4.987&&random>4.974)
			num1=2.8;
		else if(random<=4.974&&random>4.953)
			num1=2.6;
		else if(random<=4.953&&random>4.918)
			num1=2.4;
		else if(random<=4.918&&random>4.861)
			num1=2.2;
		else if(random<=4.861&&random>4.772)
			num1=2.0;
		else if(random<=4.772&&random>4.641)
			num1=1.8;
		else if(random<=4.641&&random>4.452)
			num1=1.6;
		else if(random<=4.452&&random>4.192)
			num1=1.4;
		else if(random<=4.192&&random>3.849)
			num1=1.2;
		else if(random<=3.849&&random>3.413)
			num1=1.0;
		else if(random<=3.413&&random>2.881)
			num1=0.8;
		else if(random<=2.881&&random>2.257)
			num1=0.6;
		else if(random<=2.257&&random>1.554)
			num1=0.4;
		else if(random<=1.554&&random>0.793)
			num1=0.2;
		else if(random<=0.793&&random>=0)
			num1=0.0;
		
		num1=num1+(((Math.random()*2.0)-1.0)/10.0);
		int life1=30+(int)(num1*(16/4));

		return life1;
		
	}


	
	public void actionPerformed(ActionEvent e){
		if(e.getSource()==jb1){
			EconFinal.cl1.show(EconFinal.efc, "Rules");//Rules if jb1 is clicked
		}
		if(e.getSource()==jb2){
			EconFinal.cl1.show(EconFinal.efc, "Game");//Rules if jb1 is clicked
		}
	}
}

class EconFinalG extends JPanel implements ActionListener{//This class is the container panel for the CardLayout.
	//No variables needed in this class.
	EconFinal ef1=new EconFinal();
	EconFinalM efm=new EconFinalM();
	Font f1=new Font("Sans Serif",Font.PLAIN,14);
	Font f2=new Font("Sans Serif",Font.BOLD,36);
	Color g1= ef1.Pastel[(int)Math.floor((Math.random()*7))];
	JButton jb1=new JButton("Controls");
	JButton jb2=new JButton("Statistics");
	JButton jb3=new JButton("Proceed");
	JButton jb4=new JButton("Quit");
	JTextArea jta1=new JTextArea();
	JScrollPane jsp1=new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	double[] inflation1={0.0,0.0,0.0};
	double[] realgdp1={0.0,0.0,0.0};
	double[] interest1={0.0,0.0,0.0};
	double[] unemployment1={0.0,0.0,0.0};
	double[] loans1={0.0,0.0,0.0};
	double[] inflation2={0.0,0.0,0.0};
	double[] realgdp2={0.0,0.0,0.0};
	double[] interest2={0.0,0.0,0.0};
	double[] unemployment2={0.0,0.0,0.0};
	double[] loans2={0.0,0.0,0.0};
	EconFinalG(){//constructor.
		this.setLayout(null);
		add(jb1);//button, addactionlistener, setBounds
		jb1.addActionListener(this);
		jb1.setBounds(200,340,95,30);
		add(jb2);//button, addactionlistener, setBounds
		jb2.addActionListener(this);
		jb2.setBounds(200,380,95,30);
		add(jb3);//button, addactionlistener, setBounds
		jb3.addActionListener(this);
		jb3.setBounds(200,300,95,30);
		add(jb4);//button, addactionlistener, setBounds
		jb4.addActionListener(this);
		jb4.setBounds(200,420,95,30);
		add(jta1);
		add(jsp1);
		jsp1.getViewport().add(jta1);
		jsp1.setBounds(10,80,300,200);
		jta1.setBounds(10,80,300,200);
		jta1.setEditable(false);
		jta1.setBackground(g1);
		jta1.setLineWrap(true);
	}
	public void paintComponent(Graphics g){//paintComponent().
		setBackground(g1);
		super.paintComponent(g);
		/*if(EconFinal.justclicked1){
			EconFinal.justclicked1=false;
			EconFinal.inflation+=EconFinal.inf1;
			if(EconFinal.unemployment>=4.0){
				EconFinal.unemployment+=-0.5*EconFinal.gov1;
				EconFinal.inf1=0.5*EconFinal.gov1;
			}
			else
				EconFinal.inf1=EconFinal.gov1;
			System.out.println("UNE: "+EconFinal.unemployment);
			System.out.println("GOV: "+EconFinal.gov1);
			System.out.println("INF: "+EconFinal.inf1);
			EconFinal.realgdp=EconFinal.realgdp*(1+(EconFinal.gov1-EconFinal.inf1)/100);
		}*/
		jta1.setText("This is your year number "+EconFinal.yearcount+" in office.");
		if(EconFinal.floodyear==EconFinal.yearcount){
			jta1.append("\n\nA flood has hit, causing a decrease in your \naggregate supply and your real GDP to\nshrink by 2%. Additionally, inflation has \nincreased by 2% because of this event.");

		}
		else if(EconFinal.floodyear+1==EconFinal.yearcount){
			jta1.append("\n\nYour country has successfully recovered \nfrom last year's flood.");
		EconFinal.flood=false;
		}

		if(EconFinal.crisisyear==EconFinal.yearcount){
			jta1.append("\n\nYour country's economy is hit by a severe \nfinancial crisis that causes GDP to shrink \nby 5%, unemployment to rise by 5%, and \ninflation to fall by 1%.");

		}
		else if(EconFinal.crisisyear+1==EconFinal.yearcount){
			jta1.append("\n\nYour country has started to recover from \nthe financial crisis that started last year. \nInflation has returned to its previous level, but real GDP is still down by 3% \nand unemployment is still \nup by 2%.");
			
		}
		else if(EconFinal.crisisyear+2==EconFinal.yearcount){
			jta1.append("\n\nYour country's economy is improving from \nthe crisis that started during your year \nnumber "+(EconFinal.yearcount-2)+" in office, but real GDP \nis still down 1%, and unemployment \nis still up by 2%.");
			
		}
		else if(EconFinal.crisisyear+3==EconFinal.yearcount){
			jta1.append("\n\nThe economy of your country is still \nrecovering from the financial crisis that \nstarted during your year number "+(EconFinal.yearcount-3)+" in\noffice. Real GDP and inflation have \nreturned to previous levels, but \nunemployment remains 1% higher.");
			
		}
		else if(EconFinal.crisisyear+4==EconFinal.yearcount){
			jta1.append("\n\nAfter four years of poor economic times, \nyour country's economy has fully recovered from the financial crisis that started during your year number "+(EconFinal.yearcount-4)+" in office.");
		EconFinal.crisis=false;
		}

		if(EconFinal.recessionyear==EconFinal.yearcount){
			jta1.append("\n\nYour country's economy is hit by a \nrecession caused by a decrease in \naggregate demand that causes GDP to \nshrink by 2%, unemployment to rise by\n3%, and inflation to fall by 1%.");

		}
		else if(EconFinal.recessionyear+1==EconFinal.yearcount){
			jta1.append("\n\nYour country has started to recover from \nthe recession that started last year. \nInflation has returned to its previous level, \nbut real GDP is still down by 3% and \nunemployment is still up by 2%.");
			
		}
		else if(EconFinal.recessionyear+2==EconFinal.yearcount){
			jta1.append("\n\nAfter two years of mediocre economic \ntimes, your country's economy has fully \nrecovered from the recession that \nstarted during your year number "+(EconFinal.yearcount-2)+" \nin office.");
		EconFinal.recession=false;
		}

		
		if(EconFinal.embargoyear==EconFinal.yearcount){
			jta1.append("\n\nDue to political issues, an embargo \nhas been placed on your country, cutting \noff its main supply of oil. As such, \nreal GDP has shrunk by 3%, \ninflation has risen by 2%, and \nunemployment has risen by 2%. \nThis is caused by a decrease \nin aggregate supply.");

		}
		else if(EconFinal.embargoyear+1==EconFinal.yearcount){
			jta1.append("\n\nYour country has peacefully resolved \nthe prior political issues and the \nembargo has been removed.");
		EconFinal.embargo=false;
		}
		

		g.setFont(f2);
		g.setColor(Color.BLACK);
		g.drawString("NEWS",20,43);
		g.setColor(Color.WHITE);
		g.fillRect(0,60,320,10);
		g.setFont(f1);
	}
	public void addYear(){
		
		EconFinal.govspend=EconFinal.govspend1;
		EconFinal.govspend1=EconFinal.govspend2;
		EconFinal.flattax=EconFinal.flattax1;
		EconFinal.flattax1=EconFinal.flattax2;
		EconFinal.openmkt=EconFinal.openmkt1;
		EconFinal.openmkt1=EconFinal.openmkt2;
		EconFinal.discount=EconFinal.discount1;
		EconFinal.discount1=EconFinal.discount2;
		EconFinal.reserve=EconFinal.reserve1;
		EconFinal.reserve1=EconFinal.reserve2;
		/*inflation1[0]=0.0;
		inflation1[1]=0.0;
		inflation1[2]=0.0;
		realgdp1[0]=0.0;
		realgdp1[1]=0.0;
		realgdp1[2]=0.0;
		interest1[0]=0.0;
		interest1[1]=0.0;
		interest1[2]=0.0;
		unemployment1[0]=0.0;
		unemployment1[1]=0.0;
		unemployment1[2]=0.0;
		loans1[0]=0.0;
		loans1[1]=0.0;
		loans1[2]=0.0;
		inflation2[0]=0.0;
		inflation2[1]=0.0;
		inflation2[2]=0.0;
		realgdp2[0]=0.0;
		realgdp2[1]=0.0;
		realgdp2[2]=0.0;
		interest2[0]=0.0;
		interest2[1]=0.0;
		interest2[2]=0.0;
		unemployment2[0]=0.0;
		unemployment2[1]=0.0;
		unemployment2[2]=0.0;
		loans2[0]=0.0;
		loans2[1]=0.0;
		loans2[2]=0.0;*/
		
		EconFinal.rgdp=EconFinal.realgdp;
		
		if(EconFinal.gsc||EconFinal.ftc||EconFinal.opc||EconFinal.drc||EconFinal.rrc){
			inflation1[0]=0.0;
			inflation1[1]=0.0;
			inflation1[2]=0.0;
			realgdp1[0]=0.0;
			realgdp1[1]=0.0;
			realgdp1[2]=0.0;
			interest1[0]=0.0;
			interest1[1]=0.0;
			interest1[2]=0.0;
			unemployment1[0]=0.0;
			unemployment1[1]=0.0;
			unemployment1[2]=0.0;
			loans1[0]=0.0;
			loans1[1]=0.0;
			loans1[2]=0.0;
			inflation2[0]=0.0;
			inflation2[1]=0.0;
			inflation2[2]=0.0;
			realgdp2[0]=0.0;
			realgdp2[1]=0.0;
			realgdp2[2]=0.0;
			interest2[0]=0.0;
			interest2[1]=0.0;
			interest2[2]=0.0;
			unemployment2[0]=0.0;
			unemployment2[1]=0.0;
			unemployment2[2]=0.0;
			loans2[0]=0.0;
			loans2[1]=0.0;
			loans2[2]=0.0;
		}
		if(EconFinal.gsc){
			if(EconFinal.unemployment >= 4.0){
				inflation1[0]+=EconFinal.gov1*0.1;
				interest1[0]+=EconFinal.gov1*0.5;
				inflation1[1]+=EconFinal.gov1*0.5-inflation1[0];
				realgdp1[1]+=EconFinal.realgdp*(1+5*EconFinal.gov1/100)-EconFinal.realgdp;
				interest1[1]+=EconFinal.gov1*0.5-interest1[0];
				unemployment1[1]+=EconFinal.gov1*-0.5;
				inflation1[2]-=inflation1[1]+inflation1[0];
				interest1[2]-=interest1[1]+interest1[0];
				realgdp1[2]-=realgdp1[1]+realgdp1[0];
				unemployment1[2]-=unemployment1[1]+unemployment1[0];
			}
			else{
				inflation1[0]+=EconFinal.gov1*0.2;
				interest1[0]+=EconFinal.gov1*0.5;
				inflation1[1]+=EconFinal.gov1-inflation1[0];
				realgdp1[1]+=EconFinal.realgdp*(1+5*EconFinal.gov1/100)-EconFinal.realgdp;
				interest1[1]+=EconFinal.gov1*0.5-interest1[0];
				unemployment1[1]+=EconFinal.gov1*-0.5;
				inflation1[2]-=inflation1[1]+inflation1[0];
				interest1[2]-=interest1[1]+interest1[0];
				realgdp1[2]-=realgdp1[1]+realgdp1[0];
				unemployment1[2]-=unemployment1[1]+unemployment1[0];
			}
		}
		
		if(EconFinal.ftc){
			if(EconFinal.unemployment >= 4.0){
				inflation1[0]+=EconFinal.tax1*0.05;
				interest1[0]+=EconFinal.tax1*0.5;
				inflation1[1]+=EconFinal.tax1*0.25-inflation1[0];
				realgdp1[1]+=EconFinal.realgdp*(1+4*EconFinal.tax1/100)-EconFinal.realgdp;
				interest1[1]+=EconFinal.tax1*0.5-interest1[0];
				unemployment1[1]+=EconFinal.tax1*-0.5;
				inflation1[2]-=inflation1[1]+inflation1[0];
				interest1[2]-=interest1[1]+interest1[0];
				realgdp1[2]-=0.5*(realgdp1[1]+realgdp1[0]);
				unemployment1[2]-=unemployment1[1]+unemployment1[0];
			}
			else{
				inflation1[0]+=EconFinal.tax1*0.1;
				interest1[0]+=EconFinal.tax1*0.5;
				inflation1[1]+=EconFinal.tax1*0.5-inflation1[0];
				realgdp1[1]+=EconFinal.realgdp*(1+4*EconFinal.tax1/100)-EconFinal.realgdp;
				interest1[1]+=EconFinal.tax1*0.5-interest1[0];
				unemployment1[1]+=EconFinal.tax1*-0.5;
				inflation1[2]-=inflation1[1]+inflation1[0];
				interest1[2]-=interest1[1]+interest1[0];
				realgdp1[2]-=0.5*(realgdp1[1]+realgdp1[0]);
				unemployment1[2]-=unemployment1[1]+unemployment1[0];
			}
		}
		
		if(EconFinal.opc){
			if(EconFinal.unemployment >= 4.0){
				inflation1[0]+=EconFinal.opo1*0.1;
				interest1[0]+=EconFinal.opo1*0.5;
				realgdp1[0]+=EconFinal.realgdp*(1+4*EconFinal.opo1/100)-EconFinal.realgdp;
				unemployment1[0]+=EconFinal.opo1*-0.5;
				inflation1[1]+=EconFinal.opo1*0.4;
				realgdp1[1]-=realgdp1[0];
				unemployment1[1]-=unemployment1[0];
			}
			else{
				inflation1[0]+=EconFinal.opo1*0.2;
				interest1[0]+=EconFinal.opo1*0.5;
				realgdp1[0]+=EconFinal.realgdp*(1+4*EconFinal.opo1/100)-EconFinal.realgdp;
				unemployment1[0]+=EconFinal.opo1*-0.5;
				inflation1[1]+=EconFinal.opo1*0.8;
				realgdp1[1]-=realgdp1[0];
				unemployment1[1]-=unemployment1[0];
			}
		}
		
		if(EconFinal.drc){
			EconFinal.dcr1*=3.0;
			if(EconFinal.unemployment >= 4.0){
				inflation1[0]+=EconFinal.dcr1*0.1;
				interest1[0]+=EconFinal.dcr1*0.5;
				realgdp1[0]+=EconFinal.realgdp*(1+4*EconFinal.dcr1/100)-EconFinal.realgdp;
				unemployment1[0]+=EconFinal.dcr1*-0.5;
				inflation1[1]+=EconFinal.dcr1*0.4;
				realgdp1[1]-=realgdp1[0];
				unemployment1[1]-=unemployment1[0];
			}
			else{
				inflation1[0]+=EconFinal.dcr1*0.2;
				interest1[0]+=EconFinal.dcr1*0.5;
				realgdp1[0]+=EconFinal.realgdp*(1+4*EconFinal.dcr1/100)-EconFinal.realgdp;
				unemployment1[0]+=EconFinal.dcr1*-0.5;
				inflation1[1]+=EconFinal.dcr1*0.8;
				realgdp1[1]-=realgdp1[0];
				unemployment1[1]-=unemployment1[0];
			}		
		}
		
		if(EconFinal.rrc){
			EconFinal.rsr1*=3.0;
			if(EconFinal.unemployment >= 4.0){
				inflation1[0]+=EconFinal.rsr1*0.1;
				interest1[0]+=EconFinal.rsr1*0.5;
				realgdp1[0]+=EconFinal.realgdp*(1+4*EconFinal.rsr1/100)-EconFinal.realgdp;
				unemployment1[0]+=EconFinal.rsr1*-0.5;
				inflation1[1]+=EconFinal.rsr1*0.4;
				realgdp1[1]-=realgdp1[0];
				unemployment1[1]-=unemployment1[0];
			}
			else{
				inflation1[0]+=EconFinal.rsr1*0.2;
				interest1[0]+=EconFinal.rsr1*0.5;
				realgdp1[0]+=EconFinal.realgdp*(1+4*EconFinal.rsr1/100)-EconFinal.realgdp;
				unemployment1[0]+=EconFinal.rsr1*-0.5;
				inflation1[1]+=EconFinal.rsr1*0.8;
				realgdp1[1]-=realgdp1[0];
				unemployment1[1]-=unemployment1[0];
			}		
		}

		
		if(EconFinal.gsc||EconFinal.ftc||EconFinal.opc||EconFinal.drc||EconFinal.rrc){
			inflation2[0]=inflation1[0];
			inflation2[1]=inflation1[1];
			inflation2[2]=inflation1[2];
			realgdp2[0]=realgdp1[0];
			realgdp2[1]=realgdp1[1];
			realgdp2[2]=realgdp1[2];
			interest2[0]=interest1[0];
			interest2[1]=interest1[1];
			interest2[2]=interest1[2];
			unemployment2[0]=unemployment1[0];
			unemployment2[1]=unemployment1[1];
			unemployment2[2]=unemployment1[2];
			loans2[0]=loans1[0];
			loans2[1]=loans1[1];
			loans2[2]=loans1[2];



			EconFinal.ceal1.add(new ControlEffect(EconFinal.yearcount+1,inflation2,realgdp2,interest2,unemployment2,loans2));
		}
		
		if(EconFinal.yearcount>0){
			for(int i=0; i<EconFinal.ceal1.size(); i++){
				if(EconFinal.yearcount+1==EconFinal.ceal1.get(i).getYear()){
					EconFinal.inf1+=EconFinal.ceal1.get(i).geti1()[0];
					EconFinal.realgdp+=EconFinal.ceal1.get(i).getrgdp1()[0];
					EconFinal.interest+=EconFinal.ceal1.get(i).getr1()[0];
					EconFinal.unemployment+=EconFinal.ceal1.get(i).getu1()[0];
					EconFinal.loans+=EconFinal.ceal1.get(i).getl1()[0];
				}
				else if(EconFinal.yearcount+1==EconFinal.ceal1.get(i).getYear()+1){
					EconFinal.inf1+=EconFinal.ceal1.get(i).geti1()[1];
					EconFinal.realgdp+=EconFinal.ceal1.get(i).getrgdp1()[1];
					EconFinal.interest+=EconFinal.ceal1.get(i).getr1()[1];
					EconFinal.unemployment+=EconFinal.ceal1.get(i).getu1()[1];
					EconFinal.loans+=EconFinal.ceal1.get(i).getl1()[1];
				}
				else if(EconFinal.yearcount+1==EconFinal.ceal1.get(i).getYear()+2){
					EconFinal.inf1+=EconFinal.ceal1.get(i).geti1()[2];
					EconFinal.realgdp+=EconFinal.ceal1.get(i).getrgdp1()[2];
					EconFinal.interest+=EconFinal.ceal1.get(i).getr1()[2];
					EconFinal.unemployment+=EconFinal.ceal1.get(i).getu1()[2];
					EconFinal.loans+=EconFinal.ceal1.get(i).getl1()[2];
				}
			}
		}	
		
		//EconFinal.govspend=EconFinal.govspend1;
		
		System.out.println("UNE: "+EconFinal.unemployment);
		System.out.println("GOV: "+EconFinal.gov1);
		System.out.println("INF: "+EconFinal.inf1);
		EconFinal.gsc=false;
		EconFinal.ftc=false;
		EconFinal.opc=false;
		EconFinal.drc=false;
		EconFinal.rrc=false;
		


	}
	
	public void determineEvent(){
		if(EconFinal.yearcount>EconFinal.floodyear+3){
			if((int)(Math.random()*20+1)==1){
				EconFinal.flood=true;
				EconFinal.floodyear=EconFinal.yearcount;
			}
		}
		if(EconFinal.yearcount>EconFinal.crisisyear+5){
			if((int)(Math.random()*100+1)==1){
				EconFinal.crisis=true;
				EconFinal.crisisyear=EconFinal.yearcount;
			}
		}
		if(EconFinal.yearcount>EconFinal.recessionyear+3){
			if((int)(Math.random()*10+1)==1){
				EconFinal.recession=true;
				EconFinal.recessionyear=EconFinal.yearcount;
			}
		}
		if(EconFinal.yearcount>EconFinal.embargoyear+3){
			if((int)(Math.random()*20+1)==1){
				EconFinal.embargo=true;
				EconFinal.embargoyear=EconFinal.yearcount;
			}
		}
	}
	
	public void actionPerformed(ActionEvent e){
		if(e.getSource()==jb1){

			EconFinal.cl1.show(EconFinal.efc, "Money");//Rules if jb1 is clicked
		}
		if(e.getSource()==jb2){
			EconFinal.cl1.show(EconFinal.efc, "Graphs");//Rules if jb1 is clicked
		}
		if(e.getSource()==jb3){
			EconFinal.justclicked=true;
			EconFinal.justclicked1=true;
			addYear();
			EconFinal.yearcount++;
			determineEvent();
			EconFinal.realgdp*=1.03;
			if(EconFinal.floodyear==EconFinal.yearcount){
				EconFinal.realgdp=EconFinal.realgdp*0.98;
				EconFinal.inf1+=2.0;
			}
			else if(EconFinal.floodyear+1==EconFinal.yearcount){
				EconFinal.realgdp=EconFinal.realgdp/0.98;
				EconFinal.inf1-=2.0;
			}
			if(EconFinal.crisisyear==EconFinal.yearcount){
				EconFinal.realgdp=EconFinal.realgdp*0.95;
				EconFinal.inf1-=1.0;
				EconFinal.unemployment+=5.0;
			}
			else if(EconFinal.crisisyear+1==EconFinal.yearcount){
				EconFinal.realgdp=EconFinal.realgdp/0.95*0.97;
				EconFinal.inf1+=1.0;
				EconFinal.unemployment=EconFinal.unemployment-5.0+4.0;
			}
			else if(EconFinal.crisisyear+2==EconFinal.yearcount){
				EconFinal.realgdp=EconFinal.realgdp/0.97*0.99;
				EconFinal.unemployment=EconFinal.unemployment-4.0+2.0;
			}
			else if(EconFinal.crisisyear+3==EconFinal.yearcount){
				EconFinal.realgdp=EconFinal.realgdp/0.99;
				EconFinal.unemployment=EconFinal.unemployment-2.0+1.0;
			}
			else if(EconFinal.crisisyear+4==EconFinal.yearcount){
				EconFinal.unemployment=EconFinal.unemployment-1.0;
			}
			if(EconFinal.recessionyear==EconFinal.yearcount){
				EconFinal.realgdp=EconFinal.realgdp*0.98;
				EconFinal.inf1-=1.0;
				EconFinal.unemployment+=3.0;
			}
			else if(EconFinal.recessionyear+1==EconFinal.yearcount){
				EconFinal.realgdp=EconFinal.realgdp/0.98*0.99;
				EconFinal.inf1+=1.0;
				EconFinal.unemployment=EconFinal.unemployment-3.0+1.0;
			}
			else if(EconFinal.recessionyear+2==EconFinal.yearcount){
				EconFinal.realgdp=EconFinal.realgdp/0.99;
				EconFinal.unemployment=EconFinal.unemployment-1.0;
			}

			if(EconFinal.embargoyear==EconFinal.yearcount){
				EconFinal.realgdp=EconFinal.realgdp*0.97;
				EconFinal.inf1+=2.0;
				EconFinal.unemployment+=2.0;
			}
			else if(EconFinal.embargoyear+1==EconFinal.yearcount){
				EconFinal.realgdp=EconFinal.realgdp/0.97;
				EconFinal.inf1-=2.0;
				EconFinal.unemployment=EconFinal.unemployment-2.0;
			}
			
			if(EconFinal.unemployment<=2.0){
				EconFinal.unemployment = 2.0;
			}
			
			if(EconFinal.inf1+2.5>=20.0){
				EconFinal.highinflation=true;
				EconFinal.gameover=true;
			}
			
			if(EconFinal.unemployment>=15.0){
				EconFinal.highunemployment=true;
				EconFinal.gameover=true;
			}
			System.out.println(EconFinal.endyear);
			if(EconFinal.yearcount==EconFinal.endyear){
				EconFinal.gamewin=true;
				EconFinal.gameover=true;
			}
			
			if(EconFinal.gameover){
				EconFinal.cl1.show(EconFinal.efc, "End");
			}

			repaint();
		}
		if(e.getSource()==jb4){
			EconFinal.gameover=true;
			EconFinal.cl1.show(EconFinal.efc, "End");
		}
	}
}

class EconFinalI extends JPanel implements ActionListener{//This class is the container panel for the CardLayout.
	//No variables needed in this class.
	EconFinalI(){//constructor.
	
	}
	public void paintComponent(Graphics g){//paintComponent().
	
	}
	public void actionPerformed(ActionEvent e){

	}
}

class EconFinalR extends JPanel implements ActionListener{//This class is the rules panel for the CardLayout. "r" for "rules"!
	EconFinal ef1=new EconFinal();
	Color g1= ef1.Pastel[(int)Math.floor((Math.random()*7))];
	JButton jb2=new JButton("Return");
	JTextArea jta1=new JTextArea();
	Font f1=new Font("Sans Serif",Font.PLAIN,14);
	Font f2=new Font("Sans Serif",Font.BOLD,36);	
	String s1;
	EconFinalR(){//constructor.
		this.setLayout(null);
		add(jb2);//button, addactionlistener, setBounds
		jb2.addActionListener(this);
		jb2.setBounds(200,423,95,30);
		add(jta1);
		jta1.setEditable(false);
		jta1.setBounds(10,80,300,350);
		jta1.setPreferredSize(new Dimension(40,40));
		jta1.setBackground(g1);
		jta1.setLineWrap(true);
		s1="You play the role of a benevolent dictator at \nthe mercy of your country's militia. Knowing \nthat you may be overthrown, you try to best \ncontrol the country's closed economy to the \npublic's satisfaction keeping inflation and \nunemployment in check while growing \nreal gross domestic product. \n\nYou do this with a combination of five \nmacroeconomic controls:\n- Controlling Government Spending\n- Changing Flat Tax Rate\n- Conducting Open Market Operations\n- Controlling Discount Rate\n- Controlling Reserve Requirement\n\nRandom events affecting the economy \nmay occur during your term.\n\nGood luck!";
		jta1.setText(s1);
	}
	public void paintComponent(Graphics g){//paintComponent().
		//g1= ef1.Pastel[(int)Math.floor((Math.random()*7))];
		setBackground(g1);
		super.paintComponent(g);
		g.setFont(f2);
		g.setColor(Color.BLACK);
		g.drawString("OBJECTIVE",20,43);
		g.setColor(Color.WHITE);
		g.fillRect(0,60,320,10);

		g.setFont(f1);
		g.setColor(Color.BLACK);
	}	
	public void actionPerformed(ActionEvent e){
		if(e.getSource()==jb2){
			EconFinal.cl1.show(EconFinal.efc, "Start");//Game if jb2 is clicked
		}
	}

}

class EconFinalM extends JPanel implements ActionListener, ChangeListener{//This class is the container panel for the CardLayout.
	EconFinal ef1=new EconFinal();
	Color g1= ef1.Pastel[(int)Math.floor((Math.random()*7))];
	JButton jb1=new JButton("Return");
	JTextArea jta1=new JTextArea();
	JSlider js1=new JSlider(SwingConstants.HORIZONTAL,10,30,20);
	JSlider js2=new JSlider(SwingConstants.HORIZONTAL,10,20,15);
	JSlider js3=new JSlider(SwingConstants.HORIZONTAL,80,150,100);
	JSlider js4=new JSlider(SwingConstants.HORIZONTAL,0,5,2);
	JSlider js5=new JSlider(SwingConstants.HORIZONTAL,5,15,10);
	Font f1=new Font("Sans Serif",Font.PLAIN,14);
	Font f2=new Font("Sans Serif",Font.BOLD,36);
	int g2=20;
	
	EconFinalM(){//constructor.
		this.setLayout(null);
		add(js1);
		js1.addChangeListener(this);
		js1.setBounds(10,120,300,30);
		add(js2);
		js2.addChangeListener(this);
		js2.setBounds(10,180,300,30);
		add(js3);
		js3.addChangeListener(this);
		js3.setBounds(10,240,300,30);
		add(js4);
		js4.addChangeListener(this);
		js4.setBounds(10,300,300,30);
		add(js5);
		js5.addChangeListener(this);
		js5.setBounds(10,360,300,30);
		add(jb1);//button, addactionlistener, setBounds
		jb1.addActionListener(this);
		jb1.setBounds(200,420,95,30);
	}
	public void paintComponent(Graphics g){//paintComponent().
		setBackground(g1);
		super.paintComponent(g);
		EconFinal.justclicked=false;
		g.setFont(f2);
		g.setColor(Color.BLACK);
		g.drawString("CONTROLS",20,43);
		g.setColor(Color.WHITE);
		g.fillRect(0,60,320,10);

		g.setFont(f1);
		g.setColor(Color.BLACK);
		g.drawString("GOVERNMENT SPENDING (%GDP)",20,110);
		g.drawString("FLAT TAX (%)",20,170);
		g.drawString("PURCHASE BONDS (% GDP)",20,230);
		g.drawString("DISCOUNT RATE (%)",20,290);
		g.drawString("RESERVE REQUIREMENT (%)",20,350);
		g.drawString(""+js1.getValue(),280,110);
		g.drawString(""+js2.getValue(),280,170);
		g.drawString(""+js3.getValue(),280,230);
		g.drawString(""+js4.getValue(),280,290);
		g.drawString(""+js5.getValue(),280,350);
	}
	public void actionPerformed(ActionEvent e){
		if(e.getSource()==jb1){
			EconFinal.cl1.show(EconFinal.efc, "Game");//Game if jb2 is clicked
		}
	}
	public void stateChanged(ChangeEvent e){
		if(e.getSource()==js1){
			EconFinal.gsc=true;
			EconFinal.gov1=js1.getValue()-EconFinal.govspend;
			EconFinal.govspend2=js1.getValue();
		}
		else if(e.getSource()==js2){
			EconFinal.ftc=true;
			EconFinal.tax1=EconFinal.flattax-js2.getValue();
			EconFinal.flattax2=js2.getValue();
		}
		else if(e.getSource()==js3){
			EconFinal.opc=true;
			EconFinal.opo1=js3.getValue()-EconFinal.openmkt;
			EconFinal.openmkt2=js3.getValue();
		}
		else if(e.getSource()==js4){
			EconFinal.drc=true;
			EconFinal.dcr1=EconFinal.discount-js4.getValue();
			EconFinal.discount2=js4.getValue();
		}
		else if(e.getSource()==js5){
			EconFinal.rrc=true;
			EconFinal.rsr1=EconFinal.reserve-js5.getValue();
			EconFinal.reserve2=js5.getValue();
		}
		repaint();
	}
}

class EconFinalA extends JPanel implements ActionListener{//This class is the container panel for the CardLayout.
	EconFinal ef1=new EconFinal();
	Font f1=new Font("Sans Serif",Font.PLAIN,14);
	Font f2=new Font("Sans Serif",Font.BOLD,36);
	Color g1= ef1.Pastel[(int)Math.floor((Math.random()*7))];
	JButton jb1=new JButton("Return");
	String temp;
	//No variables needed in this class.
	EconFinalA(){//constructor.
		add(jb1);//button, addactionlistener, setBounds
		jb1.addActionListener(this);
		jb1.setBounds(200,400,95,30);
		this.setLayout(null);
	}
	public void paintComponent(Graphics g){//paintComponent().
		setBackground(g1);
		super.paintComponent(g);
		g.setFont(f2);
		g.setColor(Color.BLACK);
		g.drawString("INFORMATION",20,43);
		g.setColor(Color.WHITE);
		g.fillRect(0,60,320,10);

		g.setFont(f1);
		g.setColor(Color.BLACK);
		g.drawString("Price",20,105);
		g.drawString("Level",20,121);

		g.drawString("Real GDP",157,271);
		g.drawLine(30,130,30,250);
		g.drawLine(30,250,200,250);
		g.drawLine(115,140,115,240);//LRAS
		g.drawString("LRAS",100,132);
		if(EconFinal.embargo){
			g.drawLine(35,240,135,140);//AS
			g.drawString("AS",142,145);
		}
		else{
			g.drawLine(65,240,165,140);//AS
			g.drawString("AS",172,145);
		}
		
		if(EconFinal.unemployment==4.0){
			g.drawLine(65,140,165,240);//AD
			g.drawString("AD",172,245);
		}
		else if(EconFinal.unemployment>=4.0&&!EconFinal.embargo){
			g.drawLine(35,140,135,240);//AD
			g.drawString("AD",142,245);
		}
		else{
			g.drawLine(95,140,195,240);//AD
			g.drawString("AD",202,245);
		}
		
		g.drawString("Interest",10,275);
		g.drawString("Rate",23,291);
		g.drawString("Total Loans",137,441);
		g.drawLine(30,300,30,420);
		g.drawLine(30,420,200,420);
		g.drawLine(65,310,165,410);//MD
		g.drawString("MD",172,415);
		g.drawLine(65,410,165,310);//MS
		g.drawString("MS",172,315);
		
		
		EconFinal.realgdps="".concat(Format.right(EconFinal.realgdp,5,2));
		EconFinal.inflations="".concat(Format.right(2.5+EconFinal.inf1,5,2));
		EconFinal.interests="".concat(Format.right(EconFinal.interest,5,2));
		EconFinal.unemployments="".concat(Format.right(EconFinal.unemployment,5,2));
		
		
		for(int a=0;a<EconFinal.realgdps.length();a++){
			temp=EconFinal.realgdps.charAt(EconFinal.realgdps.length()-(a+1))+temp;
			if(temp.length()%3==0&&temp.indexOf(".")!=0){
				if(temp.indexOf(",")==-1)
					temp=","+temp;
			}
			if(temp.length()-(temp.length()-temp.indexOf(","))==3&&temp.indexOf(",")>-1)
				temp=","+temp;
		}
		
		if(temp.indexOf(",")==0)
			temp=temp.substring(1,temp.length());
		
		EconFinal.realgdps=temp;
		temp="";
		
		for(int a=0;a<EconFinal.inflations.length();a++){
			temp=EconFinal.inflations.charAt(EconFinal.inflations.length()-(a+1))+temp;
			if(temp.length()%3==0&&temp.indexOf(".")!=0){
				if(temp.indexOf(",")==-1)
					temp=","+temp;
			}
			if(temp.length()-(temp.length()-temp.indexOf(","))==3&&temp.indexOf(",")>-1)
				temp=","+temp;
		}
		
		if(temp.indexOf(",")==0)
			temp=temp.substring(1,temp.length());
		
		EconFinal.inflations=temp;
		temp="";
		
		for(int a=0;a<EconFinal.interests.length();a++){
			temp=EconFinal.interests.charAt(EconFinal.interests.length()-(a+1))+temp;
			if(temp.length()%3==0&&temp.indexOf(".")!=0){
				if(temp.indexOf(",")==-1)
					temp=","+temp;
			}
			if(temp.length()-(temp.length()-temp.indexOf(","))==3&&temp.indexOf(",")>-1)
				temp=","+temp;
		}
		
		if(temp.indexOf(",")==0)
			temp=temp.substring(1,temp.length());
		
		EconFinal.interests=temp;
		temp="";
		
		for(int a=0;a<EconFinal.unemployments.length();a++){
			temp=EconFinal.unemployments.charAt(EconFinal.unemployments.length()-(a+1))+temp;
			if(temp.length()%3==0&&temp.indexOf(".")!=0){
				if(temp.indexOf(",")==-1)
					temp=","+temp;
			}
			if(temp.length()-(temp.length()-temp.indexOf(","))==3&&temp.indexOf(",")>-1)
				temp=","+temp;
		}
		
		if(temp.indexOf(",")==0)
			temp=temp.substring(1,temp.length());
		
		EconFinal.unemployments=temp;
		temp="";
		
		g.drawString("REAL GDP:",230,150);
		g.drawString("$"+EconFinal.realgdps+"T",230,170);
		
		g.drawString("INFLATION:",230,200);
		g.drawString(EconFinal.inflations+"%",230,220);
		
		g.drawString("INTEREST:",230,250);
		g.drawString(EconFinal.interests+"%",230,270);
		
		g.drawString("UNEMPLOY-",230,300);
		g.drawString("MENT",235,320);
		g.drawString(EconFinal.unemployments+"%",230,340);
		
	}
	public void actionPerformed(ActionEvent e){
		if(e.getSource()==jb1){
			EconFinal.cl1.show(EconFinal.efc, "Game");//Game if jb2 is clicked
		}

	}
}

class EconFinalE extends JPanel implements ActionListener{//This class is the container panel for the CardLayout.
	//No variables needed in this class.
	EconFinal ef1=new EconFinal();
	Font f1=new Font("Sans Serif",Font.PLAIN,14);
	Font f2=new Font("Sans Serif",Font.BOLD,36);
	Color g1= ef1.Pastel[(int)Math.floor((Math.random()*7))];
	JButton jb1=new JButton("Return");
	JTextArea jta1=new JTextArea();
	String temp;
	EconFinalE(){//constructor.
		this.setLayout(null);
		add(jb1);//button, addactionlistener, setBounds
		jb1.addActionListener(this);
		jb1.setBounds(200,423,95,30);
		add(jta1);
		jta1.setEditable(false);
		jta1.setBounds(10,200,300,80);
		jta1.setPreferredSize(new Dimension(40,40));
		jta1.setBackground(g1);
		jta1.setLineWrap(true);

	}
	public void paintComponent(Graphics g){//paintComponent().
		setBackground(g1);
		super.paintComponent(g);
		g.setFont(f2);
		g.setColor(Color.BLACK);
		g.drawString("RESULTS",20,43);
		g.setColor(Color.WHITE);
		g.fillRect(0,60,320,10);
		
		g.setColor(Color.BLACK);
		if(EconFinal.gamewin){
			g.drawString("YOU WIN",60,150);
			EconFinal.realgdps="".concat(Format.right(EconFinal.realgdp,5,2));
			for(int a=0;a<EconFinal.realgdps.length();a++){
				temp=EconFinal.realgdps.charAt(EconFinal.realgdps.length()-(a+1))+temp;
				if(temp.length()%3==0&&temp.indexOf(".")!=0){
					if(temp.indexOf(",")==-1)
						temp=","+temp;
				}
				if(temp.length()-(temp.length()-temp.indexOf(","))==3&&temp.indexOf(",")>-1)
					temp=","+temp;
			}
		
			if(temp.indexOf(",")==0)
				temp=temp.substring(1,temp.length());
			
			EconFinal.realgdps=temp;
			temp="";
			jta1.setText("You retire peacefully in relative popularity.\n\n"+"REAL GDP AT TIME OF RETIREMENT \n(this is also your score!): $"+EconFinal.realgdps+"T");
		}
		else if(EconFinal.highunemployment){
			g.drawString("YOU LOSE",60,150);
			jta1.setText("The military conducted a coup in which \nyou were killed because of dissatisfaction with the high unemployment.");
		}
		else if(EconFinal.highinflation){
			g.drawString("YOU LOSE",60,150);
			jta1.setText("The military conducted a coup in which \nyou were killed because of dissatisfaction with the high inflation.");
		}
		else
			g.drawString("GAME OVER",55,150);
		
		
		
		g.setFont(f1);
	
	}
	public void actionPerformed(ActionEvent e){
		if(e.getSource()==jb1){
			EconFinal.cl1.show(EconFinal.efc, "Start");
		}
	}
}

class ControlEffect{
	
	int year1=0;
	double[] i2;
	double[] rgdp2;
	double[] r2;
	double[] u2;
	double[] l2;
	
	public ControlEffect(int year, double[] i1, double[] rgdp1, double[] r1, double[] u1, double[] l1){
		year1=year;
		i2=i1;
		rgdp2=rgdp1;
		r2=r1;
		u2=u1;
		l2=l1;
		//System.out.println(year);
	}
	public int getYear(){
		return year1;
	}
	public double[] geti1(){
		return i2;
	}
	public double[] getrgdp1(){
		return rgdp2;
	}
	public double[] getr1(){
		return r2;
	}
	public double[] getu1(){
		return u2;
	}
	public double[] getl1(){
		return l2;
	}
}

Format.java:

//  Copy and paste this code in a jedit document, then save and
//  compile it as Format.java

public class Format
{

    public Format()
    {
    }

    public static String center(double d, int i, int j)
    {
        String s = decimalPlaces(d, j);
        if(i < s.length())
            return s;
        else
            return pad(' ', ((i - s.length()) + 1) / 2) + s + 
            pad(' ', (i - s.length()) / 2);
    }

    public static String centerSigFigs(double d, int i, int j)
    {
        String s = sigFigFix(d, j);
        if(i < s.length())
            return s;
        else
            return pad(' ', ((i - s.length()) + 1) / 2) + s + 
            pad(' ', (i - s.length()) / 2);
    }

    public static String center(long l, int i)
    {
        String s = convert(l);
        if(i < s.length())
            return s;
        else
            return pad(' ', ((i - s.length()) + 1) / 2) + s + 
            pad(' ', (i - s.length()) / 2);
    }

    public static String center(String s, int i)
    {
        if(i < s.length())
            return s;
        else
            return pad(' ', ((i - s.length()) + 1) / 2) + s + 
            pad(' ', (i - s.length()) / 2);
    }

    public static String left(double d, int i, int j)
    {
        String s = decimalPlaces(d, j);
        if(i < s.length())
            return s;
        else
            return s + pad(' ', i - s.length());
    }

    public static String leftSigFigs(double d, int i, int j)
    {
        String s = sigFigFix(d, j);
        if(i < s.length())
            return s;
        else
            return s + pad(' ', i - s.length());
    }

    public static String left(long l, int i)
    {
        String s = convert(l);
        if(i < s.length())
            return s;
        else
            return s + pad(' ', i - s.length());
    }

    public static String left(String s, int i)
    {
        if(i < s.length())
            return s;
        else
            return s + pad(' ', i - s.length());
    }

    public static String right(double d, int i, int j)
    {
        String s = decimalPlaces(d, j);
        if(i < s.length())
            return s;
        else
            return pad(' ', i - s.length()) + s;
    }

    public static String rightSigFigs(double d, int i, int j)
    {
        String s = sigFigFix(d, j);
        if(i < s.length())
            return s;
        else
            return pad(' ', i - s.length()) + s;
    }

    public static String right(long l, int i)
    {
        String s = convert(l);
        if(i <= s.length())
            return s;
        else
            return pad(' ', i - s.length()) + s;
    }

    public static String right(String s, int i)
    {
        if(i < s.length())
            return s;
        else
            return pad(' ', i - s.length()) + s;
    }

    public static String decimalPlaces(double d, int i)
    {
        double d1 = d * Math.pow(10D, i);
        d1 = Math.round(d1);
        d1 /= Math.pow(10D, i);
        return convert(d1, i);
    }

    public static String sigFigFix(double d, int i)
    {
        String s = Double.toString(d);
        String s1;
        String s2;
        if(s.startsWith("-") || s.startsWith("+"))
        {
            s1 = s.substring(0, 1);
            s2 = s.substring(1);
        } else
        {
            s1 = "";
            s2 = s;
        }
        int j = s2.indexOf(101);
        if(j == -1)
            j = s2.indexOf(69);
        String s3;
        String s4;
        if(j == -1)
        {
            s3 = s2;
            s4 = "";
        } else
        {
            s3 = s2.substring(0, j);
            s4 = s2.substring(j);
        }
        int k = s3.indexOf(46);
        StringBuffer stringbuffer;
        StringBuffer stringbuffer1;
        if(k == -1)
        {
            stringbuffer = new StringBuffer(s3);
            stringbuffer1 = new StringBuffer("");
        } else
        {
            stringbuffer = new StringBuffer(s3.substring(0, k));
            stringbuffer1 = new StringBuffer(s3.substring(k + 1));
        }
        int l = stringbuffer.length();
        int i1 = stringbuffer1.length();
        if((l == 0 || stringbuffer.equals("0")) && i1 > 0)
        {
            l = 0;
            for(int j1 = 0; j1 < stringbuffer1.length(); j1++)
            {
                if(stringbuffer1.charAt(j1) != '0')
                    break;
                i1--;
            }

        }
        int k1 = l + i1;
        if(i > k1)
        {
            for(int l1 = k1; l1 < i; l1++)
                stringbuffer1.append('0');

        } else
        if(i < k1 && i >= l)
            stringbuffer1.setLength(
            stringbuffer1.length() - (i1 - (i - l)));
        else
        if(i < l)
        {
            stringbuffer1.setLength(0);
            for(int i2 = i; i2 < l; i2++)
                stringbuffer.setCharAt(i2, '0');

        }
        if(stringbuffer1.length() == 0)
            return s1 + stringbuffer + s4;
        else
            return s1 + stringbuffer + "." + stringbuffer1 + s4;
    }

    private static String convert(double d, int i)
    {
        int j = 0;
        StringBuffer stringbuffer = new StringBuffer("" + d);
        int k;
        for(k = stringbuffer.length(); j < k && 
        stringbuffer.charAt(j) != '.'; j++);
        int l;
        if(j == k)
        {
            stringbuffer.append(".");
            l = i;
        } else
        {
            int i1 = k - j - 1;
            l = i - i1;
        }
        for(int j1 = 0; j1 < l; j1++)
            stringbuffer.append("0");

        return stringbuffer.toString();
    }

    private static String convert(long l)
    {
        return "" + l;
    }

    private static String pad(char c, int i)
    {
        StringBuffer stringbuffer = new StringBuffer("");
        if(i < 1)
            return "";
        for(int j = 0; j < i; j++)
            stringbuffer.append(c);

        return stringbuffer.toString();
    }
}

EconFinal.html:

<style>
.content{width:400px;height:500px;background-color:#FFFFFF}
body{background-color:#333333}
</style>

<br><br><br>
<center><div class="content">
<center><applet code="EconFinal.class" WIDTH = "400" HEIGHT = "550"></applet>
</center>
</div>
</center>

Priceless.gif

All the files needed to run this program are shown. Does anyone know how I can fix this to make it work in a browser?

Thanks in advance!

Edited 5 Years Ago by Germy Loo: Added link to .GIF

Attachments Priceless.gif 3.61 KB

doesn't work.

Please explain what happens.
If there are error messages in the browser's java console, copy them and paste here.

This article has been dead for over six months. Start a new discussion instead.