Coding Thread

blah blah blah what are you working on edition

I'd like someone to help me clean this method up for me please.

import java.util.Scanner;

public class Main {
public static void main(String[] args) {
int lastdigit = 0, len = 0, sum = 0, TenMinusSumModTen = 0, rem = 0;
Scanner ss = new Scanner(System.in);
System.out.print("Enter the Routing Number: ");
String s = ss.nextLine();
len = s.length();
if (len != 9) {
System.out.print("Routing Number Length not 9");
} else {
String newString = s.substring(s.length() - 1);
lastdigit = Integer.parseInt(newString);
sum = (3 * (Integer.parseInt("" + s.charAt(0)))) + (7 * (Integer.parseInt("" + s.charAt(1))))
+ (1 * (Integer.parseInt("" + s.charAt(2)))) + (3 * (Integer.parseInt("" + s.charAt(3))))
+ (7 * (Integer.parseInt("" + s.charAt(4)))) + (1 * (Integer.parseInt("" + s.charAt(5))))
+ (3 * (Integer.parseInt("" + s.charAt(6)))) + (7 * (Integer.parseInt("" + s.charAt(7))));
TenMinusSumModTen = 10 - (sum % 10);
if (TenMinusSumModTen == lastdigit)
System.out.print("Valid Routing Number");
else
System.out.print("Invalid Routing Number");

}

}
}

>s
>ss

When will these webdevs learn!?
Give your variables descriptive names, I don't care how obvious SS is to you.
FUCK.
Scanner scanner = new Scanner...

PLEASE.

don't try to disguise your support thread as a dpt thread, faggot

>webdevs
>java

named it after Hitler's SS

I was implying that it's a webdevs attempt at writing java.


You should parse your string into a int array right after reading it instead of parsing each character when required. Looks filthy, would reject PR

>newString
Oh really? No way, I thought it was a FUCKING PENIS

#include

void main(void)
{
int OP = 0;
int* OPsMomsHouse = NULL;

if (OP = fag)
{
OPsMomsHouse = my dick;
printf("Ur Gay LOL");
}
//I'm such a fucking master programmer because I can into mid level!
return windows;
}

rolling for markov chain

rollerino

That looks really retarded and I can't figure out what you are trying to achieve there,

it validates American routing numbers

Separate your IO from your calculation logic.Here's a sketch of how I'd structure your module:

// Do IO. Ask the user for number, validate length.
// construct the scanner, read in a 9-digit number.
// return as a string since that seems easy
func promptRoutingNumber(in, out io) string {
// ...
}

// Given string, either:
// return (int, nil) if the string is a valid routing number, or
// return (0, the error) if the number was not a valid routing number.
// Maybe in Java you raise an exception? I write Golang.
func newFromString(num string) (int, error) {
// ...
}


To clean up that giant mess of charAt shit, think about making a table, and using a fucking loop.

sum := 0
for idx, char := range(yourString) {
int := Integer.parseInt(string(char))
select idx {
case 0:
sum += int * 3
case 1:
sum += int * 7
// and so on, for your cases.
// ...?
}
}

ITT: everyone will roll but nobody will code shit

Yeah I kinda want a fun project where I can try out CSS animations and the likes. I could do some random code project and pick up Haskell for something fun but my CSS skills are really lacking and getting better would be awesome

rolling

What the fuck is an rss feed creator? rerolling

Rolling to see what I'm not gonna be doing.

Rolling I suppose I'll get something shitty but I won't do it regardless

Yup, FUCK THAT

roller

rolll

roll

rerolling

#include
int main()
{
int age1,age2;
printf("Enter age in year\n");
scanf("%i",&age1);
age2=age1*365*24*60*60;
printf("You have lived more than %i sec.\n",age2);
return 0;
}

maybe check if age is an integer or make my own printf scanf functions ...

Rolling for exp

Oh come on i have an american education. Rerolling

string=input("Enter your string freindo")
vowels=0

for i in string:
if(i=='a' or i=='e' or i=='i' or i=='o' or i=='u' or i=='A' or i=='E' or i=='I' or i=='O' or i=='U'):
vowels=vowels+1
print("Number of vowels is:")
print(vowels)
Rerolling

rerolling

#include
#include

int main()
{
long i,j;
long limit=100000000;
long *primes;

primes = malloc(sizeof(long)*limit);

for (i=2;i

roll

screw you I got stuff to program already

lame
int
main(void)
{
size_t i, j;
size_t length = (1000000000-1)/2;
long *sieve = malloc(sizeof(long) * length);
for (i = 0; i < length; i++)
sieve[i] = 3+2*i;
printf("2\n");
for (i = 0; i < length; i++) {
if (sieve[i] == 0)
continue;
for (j = i+sieve[i]; j < length; j += sieve[i])
sieve[j] = 0;
printf("%ld\n", sieve[i]);
}
}

BF is so easy to interpret though it's not even funny.

>008 - Love Calculator
wtf

yup you right it is useless to use the even numbers thx user

I made one for you in Python (it might me inaccurate for other users)

def hasLover():
return False

roll

???

can't be anymore unoriginal and unfunny

why the fuck is stuttering in your variable declarations any better