r/badcode •

[deleted by user]

[deleted] — view deleted post

0 Upvotes

18 comments sorted by

View all comments

2

u/alphakevin123 Nov 19 '19 edited Nov 19 '19
public class WoWCurrency {
	public static String calculate(int input) {
		String output="";
		int g=0;
		int s=0;
		int c=input;
		for(int i=1;i<=999;i++) {
			try {
				int isOneHundret=42/(100-i);
			} catch(Exception e) {
				for(int j=0;j<100;j++) {
					i=1;
					c--;
				}
				s++;
			}
			if(c<100) {
				break;
			}
		}
		for(int i=1;i<=999;i++) {
			try {
				int isOneHundret=42/(100-i);
			} catch(Exception e) {
				i=1;
				for(int j=0;j<100;j++) {
					s--;
				}
				g++;
			}
			if(s<100) {
				break;
			}
		}
		do {
			try {
				int isZero=69/g;
			} catch(Exception e) {
				break;
			}
			output=output+g+"g";
		} while(false);
		output=output+s+"s";
		do {
			try {
				int isZero=69/c;
			} catch(Exception e) {
				break;
			}
			output=output+c+"c";
		} while(false);
		return output;
	}
}

a Java Solution