Click to See Complete Forum and Search --> : Need help with this program


cystic
12-06-2007, 10:26 PM
I need this program to print out the sum of both dogs and cats
and length of array
and list only cats
and info on oldest
this is what I have so far IDK how to get the ?'s above to work in the code thanks for the help


/*
C
December 3, 2007
This uses your Animal.class to make a data-base that can go up to twenty-five animals for a vet office.
*/


import java.io.*;
class njbVet
{
public static void main (String args[]) {
throws java.IOException{
int type;
String name;
int age;
int animals;
int a;


Animals animal[] = new animal[25];


System.out.println("Type the Animal you want.")
int animals = Integer.parseInt(read.readlinr());
if(animals <= 25);
for(a = 0 a <= 25); {
System.out.println("What's it's name?");
name = readline();
System.out.println("What's it's age? ");
age = Integer.parseInt(readline());
System.out.print("what's it's type?");
System.out.println("0 is fish");
System.out.println("1 is dog");
System.out.println("2 is cat"):
System.out.println("3 is bull");
System.out.println("4 is parrot");
System.out.println("5 is cow");
System.out.println("6 is camel");
type = Intger.paresln(b.readline);
animal[a] = new animal(type, name, age);


System.out.println();
System.out.println("Animal Profile");
System.out.println("Animal Type" + animal[a] getType());
System.out.println("Animal Name" + animal[a] getName());
System.out.println("Animal Age" + animal[a] getAge());
System.out.println();
}

cystic
12-09-2007, 10:56 PM
I just want someone to explain how to do it please

ed81
12-10-2007, 08:04 AM
You have to be careful when using for loops and if staements, you are not opening and closing brackets, also, you have to update a variable eveytime you use the for loop to keep adding the amount of animals to "int animals;" until it reaches position 24. (dont forget Arrays begin at position 0, so you have to take care of that;



if(animas<=25){ //opens if statement

for(int a=0;a<animal.length;a++){ opens for loop

//code here
}//closes for loop

}//closes if statement



regards