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

Answers

Answer 1

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.


Related Questions

What are url addresses for visiting websites? And what are the different parts of a URL? Answer it in a 1-2 paragraph

Answers

A URL is a website link which consists of //https and the title of the website you are going to. A URL helps guide and memorize certain links and websites. Also some URL links are fake and give false advertisement or false information especially when looking into things that happen everyday like the news. You can tell this by seeing if the url link is a trustworthy link. I hope this helps maybe you can expand on it if it’s not long enough

Answer:

Please read explanation

Explanation:

URL is the short form for "Uniform Resource Locator". A uniform resource locator tells the location of a website to the browser.

Parts of URL:

There are three main parts of URL

ProtocolDomain nameExtension

Protocol defines the type of protocol used for communicating with the website while the domain name is the name assigned to the IP address and the mapping is stored in domain name server and extension tells the type of website i.e.

.com means commercial

.org means non-profitable organization

.edu means educational website

An additional element is path which change with the website navigation.

Other Questions
If f(x) = 4x and g(x) = x^3, then what is f(g(x))?a. 4x+x^3b. 4x^4c. 4x^3d. (4x)^3 Teams have better communication than other workers because they get to ______. a. Know each other better b. Attend communication seminars c. Earn extra benefits packages d. Use better telephones Please select the best answer from the choices provided A B C D The Chatham Island robin is a small endangered bird found in scrub forests off the coast of New Zealand. The robin is preyed upon by introduced species such as cats and rats. In 1980, the population decreased to only 5 individuals and every individual today is a descendant of a single female. Which of the following is best illustrated in the decline of the Chatham Island robins? 1. Carrying capacity2. Population bottleneck3, Population overshoot4. Type I survivorship helooooooooooooooooooooooooooo PLEASE help it's timed!! :) Given f(x) and g(x) = f(x) + k, use the graph to determine the value of k. Between Life Sciences and Physical Sciences which should be taken for Psychology in High School ? facts, figures, and other evidence learned through observation are called This month, a marching band has 60 musicians. If the number of musicians in the band last month was 51 members, what percent of increase was this? (Round to the nearest percent) 1. Which definition best defines the word "Mercantilism" A nation's wealth depends on its power A nations power depends on it wealth A nation must gain resources A nation must trade with other nations to become rich. Whats the best way to convince your teacher to help you on a quiz Which change in an object would increase the force needed to move the object?.decreasing the velocity of an objectBincreasing the volume of an objectdecreasing the mass of an objectDincreasing the mass of an object HELP PLEASE ITS MY LAST QUESTION!!Jonathan and his band want to record and sell CDs. The recording studio charges an initial set-up fee of $250, and it charges $6.00 to burn each CD.a) Define the variables: Let n = _______ Let C = _______ Felicia has a stack of 10 cards. Each card is labeled with a number in the range 1 through 10 and no two cards have the same number. She picks three cards at random from the stack and adds the numbers on the three cards. What is the expected value of the sum Does this graph represent a function? Why or why not? How does Hughes use dialogue to support his ideas in "salvation"A. There is little dialogueB. The adult's dialogue shows that they pressured the children to convince them to be savedC. The dialogue trails off as the story moves alongD. The children's dialogue reflects their maturity if someone tries to punch you and you block it with a bowl does that mean u bowled a strike What basic pattern did European colonization follow?clalm land, defend land, settle landclaim land, settle land, defend landdefend land, clalm land, settle landsettle land, defend land, claim land which ones are true? please inbox me please please please please please