Competitive/Collaborative Programming Class

ICPC Computer Programming Contest Prep

Problem Solving in Computer Science

Fall 2011 -- CSC 2700 Section 02

[Isaac's Home Page ]  [Mailing List ]  [Class Page ]  [Normal ]  

4/l/Seventeens.java

import java.util.Scanner;
//* David Stewart
// 21 September 2011
// UVA Online Problem 11879
// Multiple of 17
public class Seventeens {
	
	public static void main(String args[]) {
	Scanner in = new Scanner(System.in);
	String input = in.nextLine();
	String StringArray[] = new String[101];
	String numberString = "";
	int Dividend = 0;
	int i = 0;
	boolean boo = true;
	while (boo == true) { //cannot parse int > 11 chars
		StringArray[i] = input;
		input = in.nextLine();
		if (input.length() == 1) {
			if (Integer.parseInt(input) == 0) {
				boo = false;
			}
		}
		i++;
	}
		for (int j = 0; j < i; j++) {
			numberString = StringArray[j];
			for(int k = 0; k < numberString.length(); k++) {
				Dividend = 10*Dividend + Integer.parseInt(Character.toString(numberString.charAt(k))); //this is adding the numbers, not putting digits
				Dividend = Dividend % 17;
					if (k+1 == numberString.length()) {
						if (Dividend == 0) {
							System.out.println("1");
						} else {
							System.out.println("0");
							Dividend = 0;
						}
					}
	
			}
		}
	}
}

The statements and opinions included in these pages are those of only. Any statements and opinions included in these pages are not those of Louisiana State University or the LSU Board of Supervisors.
© 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Isaac Traxler