1answer.
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
Strike441 [17]
2 years ago
8

Define a toString prototype method that returns the cat's name, gender, and age separated by semicolons.

Computers and Technology
1 answer:
nexus9112 [7]2 years ago
6 0

Answer:

Following are the program to this question:

import java.util.*;//import package for user input

public class Main//defining main class

{

public static String Cat (String name, String gender, int age)//defining string method Cat that accept parameter value

{

return name + ';' + gender + ';' + age;//return parameter value

}

public static void main(String[] args) //defining main method

{

   String name,gender;//defining String variable

   int age;//defining integer variable

   System.out.println("Enter name, gender and age: ");//print message

   Scanner obx=new Scanner(System.in);//creating Scanner class object for user input

   name=obx.next();//input name value

   gender=obx.next();//input gender value

   age=obx.nextInt();// input age value

   System.out.println(Cat(name,gender,age));//print return method value

}

}

Output:

Enter name, gender and age:  

dani

Female

12

dani;Female;12

Explanation:

In the above-given code, a string method Cat is declared, that accepts three variable "name, gender, and age", inside the method return keyword is used that returns the parameter values.

In the main method, the above parameter variable is declared, which is used to input value from the user-end, and used the print method to print its return value.

You might be interested in
Please help, will give brainliest!!! I need help with these coding questions, any help is appreciated
olchik [2.2K]

Answer:

class Foo:

   def F(self, n):

       if n == 1:

           return 1

       return self.F(n - 1) + 3 * n - 2

Explanation:

This should cover part a to this question. The thing I'm not sure on is they use the term "method" which in python technically means a class function...but then list one argument with the function call which makes me think it is possibly just supposed to be a regular function. Which would be the following snippet. It would depend on if you are using classes or not yet in your coding class.

def F(n):

   if n == 1:

       return 1

   return F(n - 1) + 3 * n - 2

Play around with it and look into python "lists" and "for loops" for part c. Part b I'm not sure what kind of example they want since I'm not in that class. Good luck!

8 0
2 years ago
Write a Python statement that displays the value referenced by the number variable formatted as1,234,567.5
bulgar [2K]

Answer:

x = 1234567.5

print(f'{x:,}')

* there's various ways to accomplish this, but above seems to be the shortest. Requires python ≥ 3.6

8 0
3 years ago
hi, I want to ask how do I change the Brainly to another country?, because I pressed the wrong Brainly button to my country​
Setler [38]

Answer:

I don't know maybe you should Uninstall

3 0
3 years ago
Read 2 more answers
Anyone have the Dell xps 13 laptop? if not pls don't answer but if you do, how is it going for you?​
Nady [450]

I do and it’s going alright; would recommend. Here’s what I think in bullet points.

- Good aesthetic design. Weave-like texture is nice and somewhat opulent.

- Good performance; you can overclock the i7 CPU.

- Battery life is at the upper end of the spectrum.

- No USB Type A Ports, big downside.

- Graphics are about 1000 points above industry average (3D Mark Fire Spark)

- Uses an SSD rather than a HDD; much quicker load time.

- I’d go for the $1,899 personally; it’s worth the extra money.

Thanks.

3 0
2 years ago
Read 2 more answers
Which of the following is a negative effect of the rise in agricultural technology following World War II?
Whitepunk [10]
Is it a multiple choice
6 0
3 years ago
Other questions:
  • At the dsl local carrier's office, the __________ demultiplexes the data streams and converts them into digital data.
    10·1 answer
  • Which of the following identifies the patterns used for each data series in a chart?
    13·1 answer
  • The speed of sound depends on the material the sound is passing through. Below is the approximate speed of sound (in feet per se
    9·1 answer
  • Marie has never used a word processor. In 3 to 4 sentences, describe how she could benefit from using a word processor to comple
    7·2 answers
  • Consider the code fragment below. Show the values stored at each location in memory and as they change while the code executes.
    5·1 answer
  • Debug the recursive reverseString method, which is intended to return the input String str reversed (i.e. the same characters bu
    13·1 answer
  • Question :
    6·1 answer
  • What is Roko's Basilisk?
    7·1 answer
  • What is meant by the term text?
    14·2 answers
  • Kaitlin likes a particular design theme, but she is not sure about every single color for bullets, backgrounds, etc. found in th
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!