Homework Help Question & Answers

JAVA "Class and Driver Class" ~ Almost Finished ~ LIFESAVER!

Prompt:

Design and implement aclass called Dog that contains instance data thatrepresents the dog's name and age. Define theDogconstructor to accept and initialize instance data.Include getter and setter methods for the name andage. Include a method tocompute and return theage of the dog in "person years" (seven times the dog's age).Include a toString method that returns aone-linedescription of thedog.

Create adriver class called Kennel, whose main methodinstantiates and updates several Dogobjects. In thedriver class use aloop to get user input for thename and age of the dog. continue to loop until the user has nomore dogs to create.

While in the loop print out the nameof the current dog entered.

So Far Ihave the Dog class incomplete please help:

public classDog
{
private int Age = 0;
private String Name;

public Dog()
{
Value();
}

public String getName()
{
return Name;
}
public void String setName(String new Name)
{
Name = new Name;
}
public int getAge()
{
return Age;
}
public void int setAge(int new Age)
{
Age = new Age();
}
public void int personYears
{
Value = Age *7
return Value();
}
public String toString()
{
return Age;
return Name;
}
}

_________________________________________________________________________________________

Driver Classincomplete:

import java.util.Scanner;

public class Kennel
{
public static void main (String[] args)
{
String name;
int age;

Scanner scan = new Scanner(System.in);

System.out.println ( "Enter Name ofthe Dog: ");
name = scan.nextLine();

System.out.println ("Enter the age of the Dog: ");
age= scan.nextInt();

}
}

0 0
Add a comment
Answer

This Homework Help Question: "JAVA "Class and Driver Class" ~ Almost Finished ~ LIFESAVER!" No answers yet.

Be the First!

Request Answer

Request answer!

We need 10 more requests to produce the answer to this homework help question. Share with your friends to get the answer faster!

0 /10 have requested the answer to this homework help question.

Request! (Login Required) Share with friends


Once 10 people have made a request, the answer to this question will be available in 1-2 days.
All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
JAVA "Class and Driver Class" ~ Almost Finished ~ LIFESAVER!
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coin

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • LAB: Pet information (derived classes)

    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 dogBreed. 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 2 Kreacher 3 German Schnauzerthe output is:Pet Information:     Name: Dobby    Age: 2 Pet Information:     Name: Kreacher    Age: 3    Breed: German SchnauzerPetInformation.javaimport java.util.Scanner; public class PetInformation {    public static void main(String[] args) {       Scanner scnr = new Scanner(System.in);       Pet myPet = new Pet();       Dog myDog = new Dog();              String petName, dogName, dogBreed;       int petAge, dogAge;       petName = scnr.nextLine();       petAge = scnr.nextInt();       scnr.nextLine();...

  • Solve this using Java for an Intro To Java Class. Provided files: Person.java /** * Models...

    Solve this using Java for an Intro To Java Class. Provided files: Person.java /** * Models a person */ public class Person { private String name; private String gender; private int age; /** * Consructs a Person object * @param name the name of the person * @param gender the gender of the person either * m for male or f for female * @param age the age of the person */ public Person(String name, String gender, int age) {...

  • java questions: 1. Explain the difference between a deep and a shallow copy. 2. Given the...

    java questions: 1. Explain the difference between a deep and a shallow copy. 2. Given the below classes: public class Date {    private String month;    private String day;    private String year;    public Date(String month, String day, String year) {       this.month = month;       this.day = day;       this.year = year;    }    public String getMonth() {       return month;    }    public String getDay() {       return day;    }    public String...

  • Chapter 5 Assignment Read directions: In JAVA design and implement a class called Dog that contains...

    Chapter 5 Assignment Read directions: In JAVA design and implement a class called Dog that contains instance data that represents the dog's name and dog's age. Define the Dog constructor to accept and initialize instance data. Include getter and setter methods for the name and age. Include a method to compute and return the age of the dog in "person years" (seven times age of dog. Include a toString method that returns a one-time description of the dog (example below)....

  • (JAVA) Use the Pet.java program from the original problem (down below) Compile it. Create a text...

    (JAVA) Use the Pet.java program from the original problem (down below) Compile it. Create a text file named pets10.txt with 10 pets (or use the one below). Store this file in the same folder as your “class” file(s). The format is the same format used in the original homework problem. Each line in the file should contain a pet name (String), a comma, a pet’s age (int) in years, another comma, and a pet’s weight (double) in pounds. Perform the...

  • CONVERT THIS JAVA CODE WITH THE JAVA DOC GUIDELINES WHERE APPROPRIATE. DO NOT CHANGE THE CODE....

    CONVERT THIS JAVA CODE WITH THE JAVA DOC GUIDELINES WHERE APPROPRIATE. DO NOT CHANGE THE CODE. SAME CODE SHOULD BE USED FOR THE DOCUMENTATION PURPOSES. ONLY INSERT THE JAVA DOC. //Vehicle.java public class Vehicle {    private String manufacturer;    private int seat;    private String drivetrain;    private float enginesize;    private float weight; //create getters for the attributes    public String getmanufacturer() {        return manufacturer;    }    public String getdrivetrain() {        return drivetrain;...

  • In Java Create a testing class that does the following to the given codes below: To...

    In Java Create a testing class that does the following to the given codes below: To demonstrate polymorphism do the following: Create an arraylist to hold 4 base class objects Populate the arraylist with one object of each data type Code a loop that will process each element of the arraylist Call the first ‘common functionality’ method Call the second ‘common functionality’ method Call the third ‘common functionality’ method Verify that each of these method calls produces unique results Call...

  • import java.util.Scanner; public class StudentClient {       public static void main(String[] args)    {   ...

    import java.util.Scanner; public class StudentClient {       public static void main(String[] args)    {        Student s1 = new Student();         Student s2 = new Student("Smith", "123-45-6789", 3.2);         Student s3 = new Student("Jones", "987-65-4321", 3.7);         System.out.println("The name of student #1 is ");         System.out.println("The social security number of student #1 is " + s1.toString());         System.out.println("Student #2 is " + s2);         System.out.println("the name of student #3 is " + s3.getName());         System.out.println("The social security number...

  • java problems

    1)Which of the following class definitions is correct in Java?(i)public class Employee{private String name;private double salary;private int id;public Employee(){name = "";salary = 0.0;id = 0;}public Employee(String n, double s, int i){name = n;salary = s;id = i;}public void print(){System.out.println(name + " " + id + " " + salary);}}(ii)public class Employee{private String name;private double salary;private int id;public void Employee(){name = "";salary = 0.0;id = 0;}public void Employee(String n, double s, int i){name = n;salary = s;id = i;}public void print(){System.out.println(name...

  • JAVA: How do I output all the data included for each employee? I can only get...

    JAVA: How do I output all the data included for each employee? I can only get it to output the name, monthly salary and annual salary, but only from the Employee.java file, not Salesman.java or Executive.java. Employee.java package project1; public class Employee { private String name; private int monthlySalary; public Employee(String name, int monthlySalary) { this.name = name; this.monthlySalary = monthlySalary; } public int getAnnualSalary() { int totalPay = 0; totalPay = 12 * monthlySalary; return totalPay; } public String...

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