Question

This is not my entire line of code but the errors I'm getting are from this...

This is not my entire line of code but the errors I'm getting are from this section. Can you please correct it and tell me where I went wrong? Thank you!

package comJava;
Vimport java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
//Lis
public Driver {
static List<RescueAnimal> list = new ArrayList<>();
public static void main(String[] args) {

// Class variables

// Create New Dog
Dog d = new Dog();

// Create New Monkey
Monkey m = new Monkey();

// Method to process request for a rescue animal
RescueAnimal animal = getARescueAnimal();

// Method(s) to update information on existing animals
updateAnimal(animal);
list.add(animal);
// Method to display matrix of aninmals based on location and status/training phase
updateAnimal(animal);
// Method to add animals

// Method to out process animals for the farm or in-service placement

// Method to display in-service animals

// Process reports from in-service agencies reporting death/retirement
printAll();


}
public static void printAll() {
for (RescueAnimal a:list){
System.out.println(a);
}

}
public static void displayBasedOnLoc(){
String temp;
System.out.println("Enter the location to search");
Scanner sc = new Scanner(System.in);
temp = sc.next();
for (RescueAnimal a:list){
if(a.getTrainingLocation().equals(temp)){
System.out.println(a);
}
}

}
public static void displaBasedOnTraining(){
String temp;
System.out.println("Enter the status of training to search");
Scanner sc = new Scanner(System.in);
temp = sc.next();
for (RescueAnimal a:list){
if(a.getTrainingStatus().equals(temp)){
System.out.println(a);
}
}
}
public static void updateAnimal(RescueAnimal r) {
Scanner sc = new Scanner(System.in);
int choice = 0;
boolean loop = true;
do {
System.out.println("Enter 1 for Name Update");
System.out.println("Enter 2 for type Update");
System.out.println("Enter 3 for updating gender");
System.out.println("Enter 4 age Update");
System.out.println("Update 5 weight update");
System.out.println("update acquisition Date:Format:6: ");
System.out.println("update trainingStart Date:Format: 7: ");
System.out.println("update trainingend Date:8 ");
System.out.println("trainingStatus 9");
System.out.println("InServiceCountry 10");
System.out.println("InServiceCity 11");
System.out.println("INServiceAg 12");
System.out.println("InServPOC 13");
System.out.println("Reserved?True:False 14");
System.out.println("acq source 15");
// r.setAcquisitionSource(sc.next());
System.out.println("In Service Email 16");
System.out.println("17 to exit");
choice = sc.nextInt();
while (choice < 0 && choice > 18) {
choice = sc.nextInt();
}
switch (choice) {
case 1:
System.out.println("Enter name");
r.setName(sc.next());
break;
case 2:
System.out.println("enter type");
r.setType(sc.next());
break;
case 3:
System.out.println("enter gender");
r.setGender(sc.next());
break;
case 4:
System.out.println("Enter age");
r.setAge(sc.nextInt());
break;
case 5:
System.out.println("enter weight");
r.setWeight(sc.nextFloat());
break;
case 6:
System.out.println("ACq date");
r.setAcquisitionDate(LocalDate.parse(sc.next()));
break;
case 7:
System.out.println("Enter Tr st date");
r.setTrainingStart(LocalDate.parse(sc.next()));
break;
case 8:
System.out.println("enter tr end dt");
r.setTrainingEnd(LocalDate.parse(sc.next()));
break;

case 9:
System.out.println("enter tr stat");
r.setTrainingStatus(sc.next());
break;
case 10:
System.out.println("Enter country inservice");
r.setInServiceCountry(sc.next());
break;
case 11:
System.out.println("Enter serv city");
r.setInServiceCity(sc.next());
break;
case 12:
System.out.println("Enter agency");
r.setInServiceAgency(sc.next());
break;
case 13:
System.out.println("Enter poc");
r.setInServicePOC(sc.next());
break;
case 14:
System.out.println("Enter reserved:true:false");
r.setReserved(sc.nextBoolean());
break;
case 15:
System.out.println("Enter acq souce");
r.setAcquisitionSource(sc.next());
break;
case 16:
System.out.println("Enter email");
r.setInServiceEmail(sc.next());
break;
case 17:
System.out.println("Exiting:");
return;
// break;
}
} while (loop);
}

public static RescueAnimal getARescueAnimal() {
RescueAnimal r = new RescueAnimal();
rescueAnimal(r);
return r;
}

public static void rescueAnimal(RescueAnimal r) {
// RescueAnimal r = new RescueAnimal();
Scanner sc = new Scanner(System.in);
System.out.println("Enter Name");
r.setName(sc.next());
System.out.println("Enter type");
r.setType(sc.next());
System.out.println("Enter gender");
r.setGender(sc.next());
System.out.println("Enter age");
r.setAge(sc.nextInt());
System.out.println("weight?");
r.setWeight(sc.nextFloat());
System.out.println("Enter acquisition Date:Format: yyyy-mm-dd: ");
r.setAcquisitionDate(LocalDate.parse(sc.next()));
System.out.println("Enter trainingStart Date:Format: yyyy-mm-dd: ");
r.setTrainingStart(LocalDate.parse(sc.next()));
System.out.println("Enter trainingend Date:Format: yyyy-mm-dd: ");
r.setTrainingEnd(LocalDate.parse(sc.next()));
System.out.println("trainingStatus");
r.setTrainingStatus(sc.next());
System.out.println("InServiceCountry");
r.setInServiceCountry(sc.next());
System.out.println("InServiceCity");
r.setInServiceCity(sc.next());
System.out.println("INServiceAg");
r.setInServiceAgency(sc.next());
System.out.println("InServPOC");
r.setInServicePOC(sc.next());
System.out.println("Reserved?True:False");
r.setReserved(sc.nextBoolean());
System.out.println("acq source");
r.setAcquisitionSource(sc.next());
System.out.println("In Service Email");
r.setInServiceEmail(sc.next());
//goes on....

}
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
// 1 st the issue here is the class keyword is missing
public class Driver {

// need to add the RescueAnimal class according to your requirement
static List<RescueAnimal> list = new ArrayList<>();
public static void main(String[] args) {

// Class variables

// Create New Dog

// need to add the Dog class according to your requirement
Dog d = new Dog();

// Create New Monkey

// need to add the Monkey class according to your requirement
Monkey m = new Monkey();

// Method to process request for a rescue animal

// need to add the RescueAnimal class according to your requirement
RescueAnimal animal = getARescueAnimal();

// Method(s) to update information on existing animals
updateAnimal(animal);
list.add(animal);
// Method to display matrix of aninmals based on location and status/training phase
updateAnimal(animal);
// Method to add animals

// Method to out process animals for the farm or in-service placement

// Method to display in-service animals

// Process reports from in-service agencies reporting death/retirement
printAll();


}
public static void printAll() {

// need to add the RescueAnimal class according to your requirement
for (RescueAnimal a:list){
System.out.println(a);
}

}
public static void displayBasedOnLoc(){
String temp;
System.out.println("Enter the location to search");
Scanner sc = new Scanner(System.in);
temp = sc.next();
for (RescueAnimal a:list){
if(a.getTrainingLocation().equals(temp)){
System.out.println(a);
}
}

}
public static void displaBasedOnTraining(){
String temp;
System.out.println("Enter the status of training to search");
Scanner sc = new Scanner(System.in);
temp = sc.next();
for (RescueAnimal a:list){
if(a.getTrainingStatus().equals(temp)){
System.out.println(a);
}
}
}
public static void updateAnimal(RescueAnimal r) {
Scanner sc = new Scanner(System.in);
int choice = 0;
boolean loop = true;
do {
System.out.println("Enter 1 for Name Update");
System.out.println("Enter 2 for type Update");
System.out.println("Enter 3 for updating gender");
System.out.println("Enter 4 age Update");
System.out.println("Update 5 weight update");
System.out.println("update acquisition Date:Format:6: ");
System.out.println("update trainingStart Date:Format: 7: ");
System.out.println("update trainingend Date:8 ");
System.out.println("trainingStatus 9");
System.out.println("InServiceCountry 10");
System.out.println("InServiceCity 11");
System.out.println("INServiceAg 12");
System.out.println("InServPOC 13");
System.out.println("Reserved?True:False 14");
System.out.println("acq source 15");
// r.setAcquisitionSource(sc.next());
System.out.println("In Service Email 16");
System.out.println("17 to exit");
choice = sc.nextInt();
while (choice < 0 && choice > 18) {
choice = sc.nextInt();
}
switch (choice) {
case 1:
System.out.println("Enter name");
r.setName(sc.next());
break;
case 2:
System.out.println("enter type");
r.setType(sc.next());
break;
case 3:
System.out.println("enter gender");
r.setGender(sc.next());
break;
case 4:
System.out.println("Enter age");
r.setAge(sc.nextInt());
break;
case 5:
System.out.println("enter weight");
r.setWeight(sc.nextFloat());
break;
case 6:
System.out.println("ACq date");
r.setAcquisitionDate(LocalDate.parse(sc.next()));
break;
case 7:
System.out.println("Enter Tr st date");
r.setTrainingStart(LocalDate.parse(sc.next()));
break;
case 8:
System.out.println("enter tr end dt");
r.setTrainingEnd(LocalDate.parse(sc.next()));
break;

case 9:
System.out.println("enter tr stat");
r.setTrainingStatus(sc.next());
break;
case 10:
System.out.println("Enter country inservice");
r.setInServiceCountry(sc.next());
break;
case 11:
System.out.println("Enter serv city");
r.setInServiceCity(sc.next());
break;
case 12:
System.out.println("Enter agency");
r.setInServiceAgency(sc.next());
break;
case 13:
System.out.println("Enter poc");
r.setInServicePOC(sc.next());
break;
case 14:
System.out.println("Enter reserved:true:false");
r.setReserved(sc.nextBoolean());
break;
case 15:
System.out.println("Enter acq souce");
r.setAcquisitionSource(sc.next());
break;
case 16:
System.out.println("Enter email");
r.setInServiceEmail(sc.next());
break;
case 17:
System.out.println("Exiting:");
return;
// break;
}
} while (loop);
}

public static RescueAnimal getARescueAnimal() {
RescueAnimal r = new RescueAnimal();
rescueAnimal(r);
return r;
}

public static void rescueAnimal(RescueAnimal r) {
// RescueAnimal r = new RescueAnimal();
Scanner sc = new Scanner(System.in);
System.out.println("Enter Name");
r.setName(sc.next());
System.out.println("Enter type");
r.setType(sc.next());
System.out.println("Enter gender");
r.setGender(sc.next());
System.out.println("Enter age");
r.setAge(sc.nextInt());
System.out.println("weight?");
r.setWeight(sc.nextFloat());
System.out.println("Enter acquisition Date:Format: yyyy-mm-dd: ");
r.setAcquisitionDate(LocalDate.parse(sc.next()));
System.out.println("Enter trainingStart Date:Format: yyyy-mm-dd: ");
r.setTrainingStart(LocalDate.parse(sc.next()));
System.out.println("Enter trainingend Date:Format: yyyy-mm-dd: ");
r.setTrainingEnd(LocalDate.parse(sc.next()));
System.out.println("trainingStatus");
r.setTrainingStatus(sc.next());
System.out.println("InServiceCountry");
r.setInServiceCountry(sc.next());
System.out.println("InServiceCity");
r.setInServiceCity(sc.next());
System.out.println("INServiceAg");
r.setInServiceAgency(sc.next());
System.out.println("InServPOC");
r.setInServicePOC(sc.next());
System.out.println("Reserved?True:False");
r.setReserved(sc.nextBoolean());
System.out.println("acq source");
r.setAcquisitionSource(sc.next());
System.out.println("In Service Email");
r.setInServiceEmail(sc.next());
//goes on....

}
}

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me

Add a comment
Know the answer?
Add Answer to:
This is not my entire line of code but the errors I'm getting are from this...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please make the following code modular. Therefore contained in a package with several classes and not...

    Please make the following code modular. Therefore contained in a package with several classes and not just one. import java.util.*; public class Q {    public static LinkedList<String> dogs = new LinkedList<String> ();    public static LinkedList<String> cats = new LinkedList<String> ();    public static LinkedList<String> animals = new LinkedList<String> ();    public static void enqueueCats(){        System.out.println("Enter name");        Scanner sc=new Scanner(System.in);        String name = sc.next();        cats.addLast(name);        animals.addLast(name);    }   ...

  • This is what I have so far. I'm getting an error on the ... case 3:...

    This is what I have so far. I'm getting an error on the ... case 3: System.out.println("Enter the rank of the card you want removed"); cards.remove(); System.out.println(); break; -------------------------------------- package PlayingCards; import java.util.Scanner; public class Driver { public static void main(String[] args) { Scanner sc = new Scanner(System.in); boolean done = false; int menuInput; DeckOfCards cards = new DeckOfCards(); do { System.out.println("Enter the number of one of the choices below:"); System.out.println("1: Shuffle The Deck."); System.out.println("2: Print The Cards Remaining In...

  • Could someone re-write this code so that it first prompts the user to choose an option...

    Could someone re-write this code so that it first prompts the user to choose an option from the calculator (and catches if they enter a string), then prompts user to enter the values, and then shows the answer. Also, could the method for the division be rewritten to catch if the denominator is zero. I have the bulk of the code. I am just having trouble rearranging things. ------ import java.util.*; abstract class CalculatorNumVals { int num1,num2; CalculatorNumVals(int value1,int value2)...

  • Need Help ASAP!! Below is my code and i am getting error in (public interface stack)...

    Need Help ASAP!! Below is my code and i am getting error in (public interface stack) and in StackImplementation class. Please help me fix it. Please provide a solution so i can fix the error. thank you.... package mazeGame; import java.io.*; import java.util.*; public class mazeGame {    static String[][]maze;    public static void main(String[] args)    {    maze=new String[30][30];    maze=fillArray("mazefile.txt");    }    public static String[][]fillArray(String file)    {    maze = new String[30][30];       try{...

  • Provide comments for this code explaining what each line of code does import java.util.*; public class...

    Provide comments for this code explaining what each line of code does import java.util.*; public class Chpt8_Project {    public static void main(String[] args)       {        Scanner sc=new Scanner(System.in);        int [][]courses=new int [10][2];        for(int i=0;i<10;i++)        {            while(true)            {                System.out.print("Enter classes and graduation year for student "+(i+1)+":");                courses[i][0]=sc.nextInt();                courses[i][1]=sc.nextInt();                if(courses[i][0]>=1...

  • Please put both of this loops into one program. Set it up so that there is...

    Please put both of this loops into one program. Set it up so that there is one main function and both loops are within it. Thank You. import java.util.Scanner; public class WhileDavidMungomaLab12 { public static void main(String[] args) { int aScore = -1; while (aScore < 0 || aScore > 100) { Scanner sc = new Scanner(System.in); System.out.println("Please enter a valid number that is within the specified range(0 and 100): "); aScore = sc.nextInt(); } } } AND import java.util.Scanner;...

  • I need to add a method high school student, I couldn't connect high school student to...

    I need to add a method high school student, I couldn't connect high school student to student please help!!! package chapter.pkg9; import java.util.ArrayList; import java.util.Scanner; public class Main { public static Student student; public static ArrayList<Student> students; public static HighSchoolStudent highStudent; public static void main(String[] args) { int choice; Scanner scanner = new Scanner(System.in); students = new ArrayList<>(); while (true) { displayMenu(); choice = scanner.nextInt(); switch (choice) { case 1: addCollegeStudent(); break; case 2: addHighSchoolStudent(); case 3: deleteStudent(); break; case...

  • I am currently doing homework for my java class and i am getting an error in...

    I am currently doing homework for my java class and i am getting an error in my code. import java.util.Scanner; import java.util.Random; public class contact {       public static void main(String[] args) {        Random Rand = new Random();        Scanner sc = new Scanner(System.in);        System.out.println("welcome to the contact application");        System.out.println();               int die1;        int die2;        int Total;               String choice = "y";...

  • package rectangle; public class Rectangle {    private int height;    private int width;    public...

    package rectangle; public class Rectangle {    private int height;    private int width;    public Rectangle(int aHeight, int aWidth) {    super();    height = aHeight;    width = aWidth;    }    public int getHeight() {    return height;    }    public int getWidth() {    return width;    }    public void setHeight(int aHeight) {    height = aHeight;    }    public void setWidth(int aWidth) {    width = aWidth;    }    public int...

  • Online shopping cart (continued) (Java) Hello, I need help with Java to figure this out. In...

    Online shopping cart (continued) (Java) Hello, I need help with Java to figure this out. In my Shopping Cart Manager Class (Bottom Code), I get "Resource leak: 'sc' is never closed." I have tried multiple things and cannot figure it out. Thank you. Online shopping cart (continued) (Java) Hello, I need help with Java to figure this out. In my Shopping Cart Manager Class (Bottom Code), I get "Resource leak: 'sc' is never closed." I have tried multiple things and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT