File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Can't get this program to work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can Watch "Can New topic

Can't get this program to work

John Tai

Joined: Nov 03, 2002
Posts: 1
import cs1.Keyboard;
public class PetPound {
public String name;
private int age;
public String gender;

public static void main(String[] args) {

String Breed;
private int age;
String Name;

Pet (String N, int a, String B){
Name = N;
age = a;
Breed = B;
// The menu - Improve on this.
System.out.println("Welcome to the Pet Pound:");

// the menu choice.
char choice = 'z';
while (choice != 'q') {
// Print a nice menu here the choices are
// a for add a new pet
// d delete a pet ... I don't want to know that means.
// p print all the pets in the pound
// q quit the program
System.out.println("Enter Your Selection :");
choice = Keyboard.readChar();
switch(choice) {
case 'a':
System.out.println("Adding A Pet");
case 'd':
System.out.println("Delete A Pet");
case 'p':
System.out.println("Printing the Pets");
case 'q':

** Function Name:
** Description:
** Arguments: Fill This out
** Returns:
public static void addPet(){
if(Type == d){
System.out.println("Please enter the Furlength");
String FurLength = Keyboard.readString();
System.out.println("Please enter the Size of the dog");
String Size = Keyboard.readString();
pets [petCount] = new Dog(Name, Sex, Age, FurLength, Size);
else if(Type='c'){
System.out.println("Please enter the FurColor of the Cat");
String FurColor = Keyboard.readString();
System.out.println("Please enter the EyeColor of the Cat");
String EyeColor = Keyboard.readString();
pets [petCount] = new Cat(Name, Sex, Age, FurColor, EyeColor);
else if(Type='b'){
System.out.println("Please enter the FeatherColor");
String FeatherColor = Keyboard.readString();
System.out.println("Please enter the BeekColor of the Bird");
String BeekColor = Keyboard.readString();
pets [petCount] = new Bird(Name, Sex, Age, FeatherColor, BeekColor);
System.out.println("You have entered the wrong option!");

** Function Name:
** Description:
** Arguments: Fill This out
** Returns:
public static void deletePet(){
String Breed = Keyboard.Readstring();
for(int i=1; array <=i; i++){
if(pet ){
** Function Name:
** Description:
** Arguments: Fill This out
** Returns:
public static void printPets(){
int size = 10;
Dog MyArray[] = New Dog[size];
for(int i = 0; i<petcount; i++){
** Function Name: cleanUpArray
** Description: removes all the blank spaces (nulls)
** from an array.
** Arguments: Any array of Objects
** Returns: void
public static void cleanUpArray(Object a[]){
for(int i=0;i<petCount;i++){
if( a[i] == null ) {
a[i+1] = null;
** Function Name: debug
** Description: Prints some debugging info
** Arguments: none
** Returns: void
public static void debug(){
int realpets = 0;
int nulls = 0;
for(int i=0;i<pets.length;i++){
if (pets[i] == null) {
else {
System.out.println("petCount = " + petCount);
System.out.println("number of pets = " + realpets);
System.out.println("number of nulls = " + nulls);
// We put our variables down here so that we
// can keep them out of sight, We're in the
// big leagues now.
static int petCount = 0;
static final int NUMBER_OF_PETS = 10;
static Pet pets[] = new Pet[NUMBER_OF_PETS];
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
if you want folks to look at this, please tell us why and how it isn't "working" the way it should.
Also, please use the code .. /code UBB tags to preserve the code's indentation. (See the " Instant UBB Code" button below "Add Reply").

Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
John Tai,
Welcome to JavaRanch!
As Ron suggested, please surround posted code with the [code] and [/code] UBB tags in order to preserve some formatting of the code. This will likely make it easier to read and understand.
Also, when asking folks a question, taking a minute to first explain things to your Cardboard Analyst and to think about Asking a Good Question is time well spent.
Note that you have the ability to edit your own posts at the Ranch. Just click on the icon that looks like a piece of paper.
Hope to see you 'round, pardner!
Good Luck.

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
I agree. Here's the link:
subject: Can't get this program to work
It's not a secret anymore!