Question
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...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get StartedRecommended Textbook for
Java An Introduction To Problem Solving And Programming
Authors: Walter Savitch
8th Edition
0134462033, 978-0134462035
Students also viewed these Programming questions
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
View Answer in SolutionInn App