Question: JAVA - The setSpecies ( ) mutator sets field species to inputSpecies and the setName ( ) mutator sets field name to inputName. In main

JAVA
-
The setSpecies() mutator sets field species to inputSpecies and the setName() mutator sets field name to inputName. In main(), call setSpecies() and setName(), passing arguments inputSpecies and inputName, respectively.
Ex: If the input is:
snake
Taj
then the output is:
The snake's name is Taj
import java.util.Scanner;
public class AnimalData {
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
Animal animal = new Animal();
String inputSpecies;
String inputName;
inputSpecies = scnr.next();
inputName = scnr.next();
/* Your code goes here */
System.out.print("The "+ animal.getSpecies());
System.out.println("'s name is "+ animal.getName());
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!