Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Add 2 more Camel objects, but this time ask the user for inputting all the values and then print the info using the getInfo method.

Add 2 more Camel objects, but this time ask the user for inputting all the values and then print the info
using the getInfo method.

/Class Declaration
public class Camel
{
// Instance Variables
int ID;
String name;
int age;
String color;
// method 1
public String getInfo() {
return ("ID of this Camel is: "+ID+" and the name is: "
+ name+".\n It is "+ age + " years old and its color is: " +
color);
}
public static void main(String[] args) {
Camel c1 = new Camel();
c1.ID="379";
c1.name= "The Red One";
c1.age=7;
c1.color="Brown Red";
System.out.println(c1.getInfo());
}
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

To add two more Camel objects and prompt the user for input you can modify the main method as follow... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java An Introduction To Problem Solving And Programming

Authors: Walter Savitch

8th Edition

0134462033, 978-0134462035

More Books

Students also viewed these Programming questions

Question

Describe the primary concerns and hopes of ecopsychologists.

Answered: 1 week ago

Question

Prove that if Σ an is absolutely convergent, then a. an

Answered: 1 week ago