Created
September 17, 2012 17:52
-
-
Save retep998/3738755 to your computer and use it in GitHub Desktop.
All my Java work
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Triangle{ | |
private static void g1(int n1){for(int n3=0;n3<n1;n3++){g2(n1-n3-1,' '); g2(n3*2+1,'x');g3();}} | |
private static void g2(int n1, char n2){for(int n3=0;n3<n1;n3++){System.out.print(n2);}} | |
private static void g3(){System.out.println();} | |
public static void main(String[] args){g1(4);} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PeterPiper{ | |
public static void main(String[] args){ | |
final String s1="Peter",s2="Piper",s3="picked",s4="a",s5="peck",s6="of",s7="pickled",s8="peppers",s9="A",s10="If",s11="Where's",s12="the"; | |
System.out.printf("%s %s %s %s %s %s %s %s.\n",s1,s2,s3,s4,s5,s6,s7,s8); | |
System.out.printf("%s %s %s %s %s, %s %s %s.\n",s9,s5,s6,s7,s8,s1,s2,s3); | |
System.out.printf("%s %s %s %s %s %s %s %s,\n",s10,s1,s3,s4,s5,s6,s7,s8); | |
System.out.printf("%s %s %s %s %s %s %s %s %s?",s11,s12,s5,s6,s7,s8,s1,s2,s3); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MultTable{ | |
static void gtef(){cwio();xcss();vvku(1);} | |
static void dvjh(){System.out.println();} | |
static void haia(char n1){System.out.print(n1);} | |
static void tdzy(int n1){while(n1>0){haia(' ');--n1;}} | |
static void kqfj(){System.out.print(" | ");} | |
static void cwio(){tdzy(4);haia('y');wyrx(1);tdzy(1);dvjh();} | |
static void wyrx(int n1){if(n1<6){kqfj();umat(n1);haia('y');wyrx(n1+1);}} | |
static void umat(int n1){System.out.print(n1);} | |
static void nnwk(int n1){if(n1<4){haia('-');nnwk(n1+1);}} | |
static void xcss(){tdzy(2);nnwk(0);rhxq(0);dvjh();} | |
static void rhxq(int n1){if(n1<5){haia('|');nnwk(0);rhxq(n1+1);}} | |
static void vvku(int n1){if(n1<11){jejw(n1);jrip(n1,1);dvjh();vvku(n1+1);}} | |
static void ywfy(int n1){System.out.printf("%2d",n1);} | |
static void jejw(int n1){tdzy(3);ywfy(n1);} | |
static void jrip(int n1,int n2){if(n2<6){kqfj();ywfy(n1*n2);jrip(n1,n2+1);}} | |
public static void main(String[] args){gtef();} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RectArea{public static void main(String[] args){System.out.print(4.25*3.40);}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class RectArea2 { | |
static Scanner goToNeighbor() { | |
return new Scanner(System.in); | |
} | |
static double begForACupOfSugar(Scanner neighbor) { | |
System.out.print("Please enter the width of the rectangle: "); | |
return neighbor.nextDouble(); | |
} | |
static double begForSomeFlourToo(Scanner neighbor) { | |
System.out.print("Please enter the height of the rectangle: "); | |
return neighbor.nextDouble(); | |
} | |
static double bakeCookies(double sugar, double flour) { | |
return sugar*flour; | |
} | |
static void haveABakeSale(double cookies) { | |
System.out.print(cookies); | |
} | |
public static void main(String[] args) { | |
Scanner neighbor = goToNeighbor(); | |
double sugar = begForACupOfSugar(neighbor); | |
double flour = begForSomeFlourToo(neighbor); | |
double cookies = bakeCookies(sugar, flour); | |
haveABakeSale(cookies); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class ConvertTemp { | |
static Scanner goToSupermarket() { | |
return new Scanner(System.in); | |
} | |
static double purchaseIngredients(Scanner store) { | |
return store.nextDouble(); | |
} | |
static double mixDough(double ingredients) { | |
return (ingredients - 32) * 5 / 9; | |
} | |
static double bakeBread(double dough) { | |
return dough + 273; | |
} | |
static void tweet(double stuff) { | |
System.out.println(stuff); | |
} | |
public static void main(String[] args) { | |
Scanner store = goToSupermarket(); | |
double ingredients = purchaseIngredients(store); | |
double dough = mixDough(ingredients); | |
tweet(dough); | |
double bread = bakeBread(dough); | |
tweet(bread); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Lines { | |
static Scanner s; | |
static double p() { | |
return s.nextDouble(); | |
} | |
public static void main(String[] args) { | |
s = new Scanner(System.in); | |
double j = p(), k = p(); | |
System.out.println(Math.hypot(j - p(), k - p())); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner;public class Strings{ | |
static Scanner rhcr(){return new Scanner(System.in);} | |
static String xioc(Scanner lnv){return lnv.nextLine();} | |
static int krkt(Scanner nea){return nea.nextInt();} | |
static int cazs(String tlt){return tlt.length();} | |
static char vbpn(String dwc,int utj){return dwc.charAt(utj);} | |
static int rexg(int wju,int wlq){return wju-wlq;} | |
static void njdv(Scanner bsk){wdcz(xioc(bsk),krkt(bsk));} | |
static void wdcz(String mss,int wcu){ztsi(vbpn(mss,rexg(cazs(mss),wcu)));if(wvkn(wcu)){wdcz(mss,rexg(wcu,hpis()));}} | |
static void ztsi(char ada){System.out.print(ada);} | |
static boolean wvkn(int dsu){return dsu>hpis();} | |
static int hpis(){return 1;} | |
static void lgbp(String sky){System.out.print(sky);} | |
static void clsi(){lgbp("Please enter a string: \nPlease enter a value for n: \n");} | |
public static void main(String[] args){clsi();njdv(rhcr());}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
da faq did i just look at?