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 ]  

8/d/HalloweenSavingMoney.java

/**
 * Austin Howick
 * 2011 Regional Contest 4 - This is Halloween: Saving Money
 * Week 8 Homework CSC 2700
 */

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int cases = in.nextInt();
		String present = "";
		int a, b, c, sigfig;
		while (cases > 0)
		{
			present = "";
			while (in.hasNext())
			{
				char[] temp = in.next().toCharArray();
				if (temp[temp.length - 1] != '\'')
					present += " " + String.valueOf(temp);
				else
				{
					present += " " + String.valueOf(temp);
					break;
				}
			}
			present = present.substring(2, present.length() - 1);
			a = in.nextInt();
			b = in.nextInt();
			c = in.nextInt();
			sigfig = in.nextInt();
			int dim = 2*b*c + 2*a*c + 2*a*b + 6*b + 3*c;
			char[] area = String.valueOf(dim).toCharArray();
			char[] temp2 = new char[area.length];
			for (int i = 0; i < sigfig; i++)
				temp2[i] = area[i];
			for (int i = sigfig; i < area.length; i++)
				temp2[i] = '0';
			System.out.println("\"The Present " + present + " requires " + String.valueOf(temp2) + " square frightometers of paper to wrap\"");
		}
	}
}

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