Author Topic: Random simple java programs that actually do something useful.  (Read 33773 times)

0 Members and 1 Guest are viewing this topic.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Random simple java programs that actually do something useful.
« Reply #15 on: December 10, 2010, 02:39:08 am »
I remember some mods we had installed on the old Omnimaga boards were just replacing some code, CSS properties and words using javascript. It was a strange way to do it but it kinda did the job. I guess it was inevitable since Invisionfree did not let us install PHP mods.

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Random simple java programs that actually do something useful.
« Reply #16 on: December 10, 2010, 05:52:42 pm »
yeongJIN_COOL's random calc generator
have fun
I got...
Spoiler For Spoiler:
TI-MICROWAVE

Code: [Select]
import java.util.*;
public class randomcalc
{
   public static void main(String args[])
   {
       Random generator = new Random();
       int r = generator.nextInt(20);
       System.out.println("yeongJIN_COOL's random calc gen");
       System.out.println("You get...");//WHAT YOU'RE GONNA GET?
       switch(r)
       {
          case 0: System.out.println("TI-81");break;
          case 1: System.out.println("TI-83+");break;
          case 2: System.out.println("TI-84+");break;
          case 3: System.out.println("TI-83+ SE");break;
          case 4: System.out.println("TI-84+ SE");break;
          case 5: System.out.println("TI-86");break;
          case 6: System.out.println("TI-89");break;
          case 7: System.out.println("TI-89 Titanium");break;
          case 8: System.out.println("TI-92");break;
          case 9: System.out.println("Voyage 200");break;
          case 10: System.out.println("TI-32 stuff");break;
          case 11: System.out.println("f(x)-9750g");break;
          case 12: System.out.println("cf(x)-9750g");break;//AT LEAST, IT HAS COLOR
          case 13: System.out.println("TI-MICROWAVE");break;//ROFL
          case 14: System.out.println("CASIO PRIZM");break;
          case 15: System.out.println("TI-nSPIRE with Clickpad");break;
          case 16: System.out.println("TI-nSPIRE with Touchpad");break;
          case 17: System.out.println("TI-nSPIRE CAS");break;
          case 18: System.out.println("Wabbitemu");break;
          case 19: System.out.println("Nothing");break;//TOO BAD FOR YOU
       }
}
}


Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Random simple java programs that actually do something useful.
« Reply #17 on: December 10, 2010, 10:27:16 pm »
nice, yeong!


next java mini-project i'm working on: linear equation solver (via rref).
done. here's the code, it's fairly obfuscated.... so good luck if you want to understand it.

Code: [Select]
import java.util.Scanner;

public class Solve{
static double[][] matrix;
public static void main(String[] args){
Scanner reader = new Scanner(System.in);
System.out.print("# of variables: ");
int vars = reader.nextInt();
inputValues(vars,vars+1);
for(int col = 0; col < vars; col++){
for(int row = 0; row < vars; row++){
if(row==0)
matrix[col] = rowDiv(matrix[col],matrix[col][col]);
if(row!=col)
matrix[row] = rowAdd(rowDiv(matrix[col],-1/matrix[row][col]),matrix[row]);

}
}
for(int i = 0; i < vars; i++)
System.out.println("xyzuvw".substring(i,i+1) + "= " + Math.round(matrix[i][vars]*1000)/1000.0);

}

public static void inputValues(int rows, int columns){
String equ = "Ax+By+Cz+Du+Ev+Fw".substring(0,rows*3-1) + "=" + "ABCDEFG".substring(rows,rows+1);
matrix = new double[rows][columns];
Scanner reader = new Scanner(System.in);
for(int r = 0; r < rows; r++){
System.out.println("Enter equation " + (r+1) + ": \n" + equ);
for(int c = 0; c < columns; c++){//C++
System.out.print("ABCDEFG".substring(c,c+1)+"= ");
matrix[r][c] = reader.nextInt();
}
System.out.println();
}
}

public static double[] rowDiv(double[] r, double c ){
double[] temp = new double[r.length];
for(int p = 0; p < r.length; p++)
temp[p] = r[p] / c;
return temp;
}

public static double[] rowAdd(double[] i, double[] j){
double[] temp = new double[i.length];
for(int p = 0; p < i.length; p++)
temp[p] = i[p] + j[p];
return temp;
}
}

it can take up to 6 variables, but as far as i know if i modified it a little, it could take an infinite number. it returns numbers to the thousandth decimal place. oh, and it will not tell you if there are no solutions/infinite solutions. it will likely do one of the following things in either of these scenarios:
-tell you that all the variables are 0.
-tell you that all the variables are NaN (not a number)
-tell you that all the variables are either -Infinity or Infinity.
« Last Edit: December 11, 2010, 12:20:03 am by nemo »


Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Random simple java programs that actually do something useful.
« Reply #18 on: December 11, 2010, 01:20:47 am »
Lol nice stuff guys XD

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Random simple java programs that actually do something useful.
« Reply #19 on: December 11, 2010, 11:09:03 am »
@nemo: I remember we had to do the linear equation solver 7 weeks ago in APCS.
Looks good! Yours have more feature.
Sig wipe!

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Random simple java programs that actually do something useful.
« Reply #20 on: December 11, 2010, 04:29:03 pm »
it was fun to make. i don't know what i want to make next though.


Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Random simple java programs that actually do something useful.
« Reply #21 on: December 12, 2010, 02:49:39 pm »
Port Reuben Quest 1 and 2 to java! ;D

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Random simple java programs that actually do something useful.
« Reply #22 on: December 12, 2010, 08:10:27 pm »
lol that's not simple :P


Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Random simple java programs that actually do something useful.
« Reply #23 on: December 13, 2010, 08:14:17 am »
I don't even know how to put graphic on java...
 :(
Sig wipe!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Random simple java programs that actually do something useful.
« Reply #24 on: December 13, 2010, 05:05:41 pm »
lol that's not simple :P
Aww, ok then D:

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Random simple java programs that actually do something useful.
« Reply #25 on: December 13, 2010, 05:09:26 pm »
I don't even know how to put graphic on java...
 :(

do you want an example program? it isn't too difficult, i could make an overly-commented program where you move a ball around with the arrow keys if you want.

by the way, what IDE do you program in?
« Last Edit: December 13, 2010, 05:11:03 pm by nemo »


Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Random simple java programs that actually do something useful.
« Reply #26 on: December 13, 2010, 06:47:29 pm »
sure!
I use BlueJ if that's what you're asking
Sig wipe!

Offline FinaleTI

  • Believe in the pony that believes in you!
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1830
  • Rating: +121/-2
  • Believe in the pony that believes in you!
    • View Profile
    • dmuckerman.tumblr.com
Re: Random simple java programs that actually do something useful.
« Reply #27 on: December 13, 2010, 07:14:20 pm »
I don't even know how to put graphic on java...
 :(
Me too.
I'd appreciate the example as well.

I'm using BlueJ too, but that's because what my AP Comp Sci class has to use. It really annoys me at times, though it's much less annoying since I figured out the keyboard shortcut for auto-indenting your class.


Spoiler For Projects:

My projects haven't been worked on in a while, so they're all on hiatus for the time being. I do hope to eventually return to them in some form or another...

Spoiler For Pokemon TI:
Axe port of Pokemon Red/Blue to the 83+/84+ family. On hold.

Spoiler For Nostalgia:
My big personal project, an original RPG about dimensional travel and a few heroes tasked with saving the world.
Coding-wise, on hold, but I am re-working the story.

Spoiler For Finale's Super Insane Tunnel Pack of Doom:
I will be combining Blur and Collision Course into a single gamepack. On hold.

Spoiler For Nostalgia Origins: Sky's Story:
Prequel to Nostalgia. On hold, especially while the story is re-worked.

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Random simple java programs that actually do something useful.
« Reply #28 on: December 13, 2010, 07:15:40 pm »
I use BlueJ because I AM in APCS
only shortcut I learned in there was ctrl+k, which was compiling
Sig wipe!

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Random simple java programs that actually do something useful.
« Reply #29 on: December 13, 2010, 07:17:51 pm »
i'm in APCS as well, i use JCreator Lite. my teacher got the free version before it started costing money.
i'll have some code up in a sec. do you guys know what a JFrame or JPanel are or should i comment the basic elements too?