jwbri
jwbri
22.02.2021 • 
Computers and Technology

LAB: Pet information (derived classes) The base class Pet has private fields petName, and petAge. The derived class Dog extends the Pet class and includes a private field for dog Breed. Complete main() to: • create a generic pet and print information using printinfo(). • create a Dog pet, use printInfo() to print information, and add a statement to print the dog's breed using the getBreed method. Ex. If the input is: Dobby Kreacher German Schnauzer the output is: Pet Information: Name: Dobby Age: 2 Pet Information: Name: Kreacher Age: 3 Breed: German Schnauzer LAB ACTIVITY 100 10.9.1: LAB: Pet information (derived classes) 0/10 Current file: PetInformation.java - Load default template... 1 import java.util.Scanner; public class Pet Information { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); Pet my Pet = new Pet(); Dog myDog = new Dog(); String petName, dogName, dogBreed; int petAge, dogAge; petName = scnr.nextLine(); petAge = scnr.nextInt(); scnr.nextLine(); dogName = scnr.next(); dogAge = scnr.nextInt(); scnr.nextLine(); dogBreed = scnr.nextLine();

Solved
Show answers

Ask an AI advisor a question