[java] please ignore
//this is to transmit home to work
import java.awt.*;
public class FirstProgram
{
public static void main(String[] args)
{
System.out.println("This is a test.");
System.out.println("currently testing");
System.out.println("For loops and arrays");
int STRatt, INTatt, SPDatt;
int ctr;
int attarr[];
attarr = new int[8];
for(ctr = 0; ctr <= 9; ctr++){
attarr[ctr] = (int)(Math.random()*6)+
(int)(Math.random()*6)+(int)(Math.random()*6);
if (attarr[ctr] > 14)
attarr[ctr] = attarr[ctr] + ((int)(Math.random()*6));
}
STRatt = attarr[1];
System.out.println("<"+ STRatt +">");
}
}
//thank you for your cooperation
// getting runtime error
// Exception Occurred:
//java.lang.ArrayIndexOutOfBoundsException
// at FirstProgram.main(Compiled Code)
// at //com.apple.mrj.JManager.JMStaticMethodDispatcher.run(JMAWTContex//tImpl.java)
// at java.lang.Thread.run(Thread.java)
"do you like my helmut?"-yoghurt
May 23, 2001 08:23 AM
import java.awt.*;
public class FirstProgram
{
public static void main(String[] args)
{
System.out.println("This is a test.");
System.out.println("currently testing");
System.out.println("for loop");
int STRatt, INTatt, SPDatt, LDRatt;
byte ctr, Att1;
//initialize variables
STRatt = 0; INTatt = 0; SPDatt = 0; LDRatt = 0;
ctr = 1; Att1 = 0;
//generate number for Strenght stat
STRatt = (int)(Math.random()*6)+
(int)(Math.random()*6)+(int)(Math.random()*6);
if (STRatt > 14)
STRatt = STRatt + ((int)(Math.random()*6));
//getting error because of int=byte
//
// for(ctr = 1; Att1 > 0;ctr++);
// { if (STRatt = ctr)
// Att1=ctr;
// }
//forget int=byte, use bubble sort
//Intelligence
INTatt = (int)(Math.random()*6)+
(int)(Math.random()*6)+(int)(Math.random()*6);
if (INTatt > 14)
INTatt = INTatt + ((int)(Math.random()*6));
//Speed
SPDatt = (int)(Math.random()*6)+
(int)(Math.random()*6)+(int)(Math.random()*6);
if (SPDatt > 14)
SPDatt = SPDatt + ((int)(Math.random()*6));
//Leadership
LDRatt = (int)(Math.random()*6)+
(int)(Math.random()*6)+(int)(Math.random()*6);
if (LDRatt > 14)
LDRatt = LDRatt + ((int)(Math.random()*6));
System.out.println("Strength = " + STRatt);
System.out.println("Intelligenge = " + INTatt);
System.out.println(" Speed = " + SPDatt);
System.out.println("Leadership = " + LDRatt);
}
}
public class FirstProgram
{
public static void main(String[] args)
{
System.out.println("This is a test.");
System.out.println("currently testing");
System.out.println("for loop");
int STRatt, INTatt, SPDatt, LDRatt;
byte ctr, Att1;
//initialize variables
STRatt = 0; INTatt = 0; SPDatt = 0; LDRatt = 0;
ctr = 1; Att1 = 0;
//generate number for Strenght stat
STRatt = (int)(Math.random()*6)+
(int)(Math.random()*6)+(int)(Math.random()*6);
if (STRatt > 14)
STRatt = STRatt + ((int)(Math.random()*6));
//getting error because of int=byte
//
// for(ctr = 1; Att1 > 0;ctr++);
// { if (STRatt = ctr)
// Att1=ctr;
// }
//forget int=byte, use bubble sort
//Intelligence
INTatt = (int)(Math.random()*6)+
(int)(Math.random()*6)+(int)(Math.random()*6);
if (INTatt > 14)
INTatt = INTatt + ((int)(Math.random()*6));
//Speed
SPDatt = (int)(Math.random()*6)+
(int)(Math.random()*6)+(int)(Math.random()*6);
if (SPDatt > 14)
SPDatt = SPDatt + ((int)(Math.random()*6));
//Leadership
LDRatt = (int)(Math.random()*6)+
(int)(Math.random()*6)+(int)(Math.random()*6);
if (LDRatt > 14)
LDRatt = LDRatt + ((int)(Math.random()*6));
System.out.println("Strength = " + STRatt);
System.out.println("Intelligenge = " + INTatt);
System.out.println(" Speed = " + SPDatt);
System.out.println("Leadership = " + LDRatt);
}
}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement