answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
qaws [65]
2 years ago
10

Write a program that implements a class called Dog that contains instance data that represent the dog's name and age. • define t

he Dog constructor to accept and initialize instance data. • create a method to compute and return the age of the dog in "person-years" (note: dog age in person-years is seven times a dog's age). • Include a toString method that returns a one-line description of the dog • Write a driver class called Kennel, whose main method instantiated and updates several Dog objects
Computers and Technology
1 answer:
g100num [7]2 years ago
7 0

Answer:

<u>Dog.java:</u>

Dog{

   //Declare instance variables

   private String name;

   private int age;

   

   //Create the constructor with two parameters, and initialize the instance variables

   public Dog(String name, int age){

       this.name = name;

       this.age = age;

   }

   

   //get methods

   public String getName(){

       return name;

   }

   

   public int getAge(){

       return age;

   }

   

   //set methods

   public void setName(String name){

       this.name = name;

   }

   

   public void setAge(int age){

       this.age = age;

   }

   

   //calculateAgeInPersonYears() method to calculate the age in person years by multiplying the age by 7

   public int calculateAgeInPersonYears(){

       return 7 * getAge();

   }

   

   //toString method to return the description of the dog

   public String toString(){

       return "Name: " + getName() + ", Age: " + getAge() + ", Age in Person Years: " + calculateAgeInPersonYears();

   }

}

<u>Kennel.java:</u>

public class Kennel

{

public static void main(String[] args) {

          //Create two dog objects using the constructor

          Dog dog1 = new Dog("Dog1", 2);

          Dog dog2 = new Dog("Dog2", 5);

          //Print their information using the toString method

          System.out.println(dog1.toString());

          System.out.println(dog2.toString());

          //Update the first dog's name using setName method

          dog1.setName("Doggy");

          System.out.println(dog1.toString());

          //Update the second dog's age using setAge method

          dog2.setAge(1);

          System.out.println(dog2.toString());

}

}

Explanation:

*The code is in Java.

You may see the explanations as comments in the code

You might be interested in
Show how the recursive multiplication algorithm computes XY, where X = 1234 and Y = 4321. Include all recursive computations.
lozanna [386]

Answer:

The result of recursive multiplication algorithm is 5332114 . Here karatsuba algorithm with recursive approach is used to compute XY where X = 1234 and Y = 4321.

Explanation:

The steps for karatsuba algorithm with recursive approach:

base case:

if(X<10) or (Y<10) then multiply X with Y

For example if X is 1 and Y is 2. Then XY = 1*2 = 2

Recursive case:

Now when the above if condition is not true then follow these steps to compute XY

Compute the size of numbers.

Notice that there are 4 digits in X i.e. 1 2 3 4 and a 4 digits in Y i.e. 4 3 2 1

So n = 4

Now divide the numbers in 2 parts as:

n/2 = 4/2 = 2

Since these are decimal numbers so we can write it as:

10^n/2

Now split the digits

X = 1234 is divided into 2 parts as:

12 and 34

Let a represent the first part and b represent the second part of X. So,

a = 12

b = 34

Y = 4321 is divided into 2 parts as:

43 and 21

Let c represent the first part and d represent the second part of Y. So,

c = 43

d = 21

Let multiplication reprsents the karatsuba recursive multiplication algorithm

Now recursively compute products of inputs of size n/2  

   multiplication (a, c)

   multiplication (b, d)

   multiplication (add(a, b), add(c, d))  

  Combine the above 3 products to compute XY  

As we know these decimal numbers have base 10 and X and Y are divided into two parts So X can be written as:

X = 10^{\frac{n}{2} }  a+b

Y can be written as:

Y = 10^{\frac{n}{2} }  c+d

Now compute XY as:

XY = (10^{\frac{n}{2} }  a+b) ( 10^{\frac{n}{2} }  c+d)

XY = 10^{\frac{2n}{2} }  ac + 10^{\frac{n}{2} }  ad +  10^{\frac{n}{2} }  bc + bd

     =  10^{n}  ac + 10^{\frac{n}{2} } (ad + bc) + bd

Now put the values of n = 4, a = 12, b = 34 , c = 43 and d = 21

      = 10⁴ (12*43) + 10² (12*21 + 34*43) + (34*21)

      = 10⁴ (516) + 10² (252 + 1462) + 714

      = 10000*516 + 100*1714 + 714

      = 5160000 + 171400 + 714

XY  = 5332114

Hence the karatsuba multiplication algorithm with recursive appraoch computes XY = 5332114

3 0
2 years ago
Sean is forecasting the time and cost of developing a customized software program by looking at the number of inputs, outputs, i
Gwar [14]

Sean is using FUNCTION POINT (d) method for forecasting the time and cost of developing a customized software program by looking at the number of inputs, outputs, inquiries, files, and interfaces.

Explanation:

  • The function point is a "unit of measurement" to express the amount of business functionality an information system (as a product) provides to a user.
  • The outcome of a function point count provides the metric 'unit of software delivered' and can be used to assist in the management and control of software development, customisation or major enhancements from early project planning phases, through to the ongoing support of the application.

6 0
2 years ago
"There are no longer mature industries; rather, there are mature ways of doing business," he is referring to the high demand of
yanalaym [24]

Hi, you've asked an incomplete and unclear question. However, I provided the full text below.

Explanation:

The text reads;

<em>"When Porter says “There are no longer mature industries; rather, there are mature ways of doing business,” he is referring to the high demand for creativity and innovation in the market. Earlier we used to be more concerned about the hardware and the physical product rather than its information content, But now as a business, we need to provide more informative content with the product.</em>

<em>Like General Electric offers dedicated customer service for its line of goods which differentiates it from its rivals. Similarly, shipping companies like UPS now offer us to track the location of our package on a live map. This is what we call a mature business and how we can differentiate ourselves and stand out in the highly competitive market by using Information and Technology..."</em>

4 0
2 years ago
Anime question where do i watch Itadaki! Seieki! 100 points
EastWind [94]

Answer:

Crunchyroll or Funamation

Explanation:

8 0
2 years ago
Read 2 more answers
You live "out in the middle of nowhere" and feel there is no need to protect your internet connection because there is no one th
Anvisha [2.4K]

Potential uploaded viruses, personal information being lost, blackmail, identity theft.

7 0
2 years ago
Other questions:
  • Consider a simple application level protocol built on top of udp that allows a client to retrieve a file from a remote server re
    15·2 answers
  • Jamie is preparing a presentation on his laptop for his college annual event. He inserts audio and video files into the presenta
    11·2 answers
  • In the game of $Mindmaster$, secret codes are created by placing pegs of any of seven different colors into four slots. Colors m
    5·1 answer
  • While trying to solve a network issue, a technician made multiple changes to the current router configuration file. The changes
    7·1 answer
  • A class of Students was previously defined with the following properties: a string name, an integer age, a Boolean variable indi
    14·1 answer
  • Now that the classList Array has been implemented, we need to create methods to access the list items.
    5·1 answer
  • Why is accessing a disk block expensive? discuss the time components involved in accessing a disk block. (?
    9·1 answer
  • Imagine a business where there are no clear boundaries defined for data and systems ownership. As a security professional, descr
    11·1 answer
  • Explain working principle of computer?​
    13·1 answer
  • The Coins class was created to hold all your loose change, kind of like a piggy bank! For this exercise, you are going to simula
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!