Answered step by step
Verified Expert Solution
Question
1 Approved Answer
When using toString method it prints the wrong answers. In the main method, a coach with parameters was created yet it still prints the default
When using toString method it prints the wrong answers. In the main method, a coach with parameters was created yet it still prints the default values.
What action would you like to perform? A Please enter the Coach's information: Enter coach's first name: John Enter coach's last name: Smith Enter coach's years of experience: 5 5 Please enter the Team's information: Enter teams name: Stars Enter Team's city: Super What action would you like to perform? Team's name: Stars from Super Coach Information: LastName: ? FirstName: ? Years of Experience 0 What action would you like to perform? public String toString() { String result = ""; result += " LastName: \t" + firstName + " FirstName: \t" + lastName + " Years of Experience\t" + years + " "; return result; } = "?"; public Coach() // default constructor { firstName lastName "?"; years = 0; } public Coach (String newFirstName, String newLastName, int newYears) { firstName = newFirstName; lastName = newLastName; years = newYears; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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 Started