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 org.junit.Test; | |
public class BetterProgrammer05122012Test extends junit.framework.TestCase { | |
public static int[] numbers = new int[] {5, 10, -5, 0, 25, 35}; | |
public static int[] numbers2 = new int[] {5, 10, -5, -2, 0, 25, 35}; | |
public static int[] noNegativeNumbers = new int[] {5, 10, 15, 25, 35}; | |
@Test | |
public void testBetterProgrammer05122012 () { |
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 org.junit.Test; | |
public class BetterProgrammingTaskTest extends junit.framework.TestCase { | |
public static String numbers = "5 25 35 5" ; | |
@Test | |
public void testGetSumOfNumbers() throws Exception { | |
assertEquals(70, BetterProgrammingTask.getSumOfNumbers(numbers)); | |
} | |
} |
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.Random; | |
import java.util.Scanner; | |
public class MultiDimArray { | |
static Random rand = new Random(); | |
static int count = 0; | |
public static void main(String[] args) { | |
// 3-D array with fixed length: |
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.text.DecimalFormat; | |
import java.util.Scanner; | |
public class SalesTaxInput { | |
public static void main(String[] args){ | |
System.out.print("What are your taxable sales? "); | |
double sales = getInput(); | |
sales = SalesTax.roundTwoDecimals(sales); | |
System.out.print("What is your sales tax rate? 1% = .01: "); |
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 PickANumber { | |
private static int a = (int) (Math.random() * 10 + 1); | |
public static void main (String[] args) { | |
for (int i = 0; i < 5; ++i) { | |
System.out.print("Pick a number from 1 to 10: "); | |
Scanner in = new Scanner (System.in); | |
int b = Integer.parseInt(in.next()); |
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; | |
class Alphabet { | |
static String[] fields = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", | |
"k", "l", "m", "n", "o", "p", "q", "r", "s", "t", | |
"u", "v", "w", "x", "y", "z"}; | |
public static void main(String[] args) { | |
String letter = null; | |
letter = pickALetter(letter); |