Wednesday, September 28, 2011

First Run-In With Methods

Purpose of this program: Create a multiplication flashcard generator for a young relative, and have it repeat 10 times.

package lab3;
//Importing Random Class
import java.util.Random;
import java.util.Scanner;

public class Rand
 public static void main(String[] args)

 public static void flashcards()
  // Inputs

  Scanner in = new Scanner(;
  Random rand = new Random();
  int randomNumber = rand.nextInt(11);

  int randomNumber2 = rand.nextInt(11);
  // Outputs
  System.out.print("What is " + (randomNumber) + " x " + (randomNumber2)
    + "? ");

  // Inputs
  int answer = in.nextInt();
  String answerString = "";
  answerString = Integer.toString(answer);

  System.out.println("Your answer: " + answer);
  System.out.println("Correct answer: "
    + String.valueOf(randomNumber * randomNumber2));

  String randomEquation = String.valueOf(randomNumber * randomNumber2);
  // Outputs
  if (answerString.equals(randomEquation))

  if (!answerString.equals(randomEquation))


Wednesday, September 14, 2011

Chapter 1 Practice Code

Here are some generic codes, along with what they print:

System.out.println("Slashes \\//");
System.out.println("How '\"confounding' \"\\\" it is!");


System.out.println("Shaq is 7'1");
System.out.println("The string \"\" is an empty message.");

Here is the output generated:

Slashes \//
How '"confounding' "\" it is!
name age height
Archie 17 5'9"
Betty 17 5'6"
Jughead 16 6'
Shaq is 7'1
The string "" is an empty message.

This may seem like a lot of useless tidbits, but the main point was to decide which characters do what in java. We learned /t is some kind of table separating function (mind you I'm doing these without any prior knowledge so be gentle if I'm way off. The rest seemed pretty straightforward.

This little post will help you solve the problems:
confounding, Archie, and Shaq on the site for Building Java Programs: Practice-It!

Wednesday, April 6, 2011

Still Sidetracked

Just can't get going on this stuff. I'm trying my best though. Stay tuned.

blogger templates | Make Money Online