Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given main(), define the Team class (in file Team.java). Forclass method getWinPercentage(), the formula is: wins / (wins + losses). Note: Use casting to prevent

Given main(), define the Team class (in file Team.java). Forclass method getWinPercentage(), the formula is:
wins / (wins + losses). Note: Use casting to prevent integerdivision.

For class method printStanding(), output the win percentage ofthe team with two digits after the decimal point and whether theteam has a winning or losing average. A team has a winning averageif the win percentage is 0.5 or greater.

Ex: If the input is:

Ravens133 

where Ravens is the team's name, 13 is the number of team wins,and 3 is the number of team losses, the output is:

Win percentage: 0.81Congratulations, Team Ravens has a winning average!

Ex: If the input is:

Angels8082

the output is:

Win percentage: 0.49Team Angels has a losing average.

On the homework this part can not change onWinningteam.java

import java.util.Scanner;

public class WinningTeam {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);

Team team = new Team();

String name = scnr.next();
int wins = scnr.nextInt();
int losses = scnr.nextInt();

team.setName(name);
team.setWins(wins);
team.setLosses(losses);

team.printStanding();
}
}

This is the part that i need to change onTeam.java

public class Team {

private String teamName;
private int teamWins;
private int teamLosses;

public String getTeamName() {
return teamName;
}

public void setTeamName(String teamName) {
this.teamName = teamName;
}

public int getTeamWins() {
return teamWins;
}

public void setTeamWins(int teamWins) {
this.teamWins = teamWins;
}

public int getTeamLosses() {
return teamLosses;
}

public void setTeamLosses(int teamLosses) {
this.teamLosses = teamLosses;
}

public double getWinPercentage() {
return teamWins / (double) (teamWins + teamLosses);
}
}

Step by Step Solution

3.44 Rating (157 Votes )

There are 3 Steps involved in it

Step: 1

Teamjava public class Team private String teamName private int teamWins private int teamLosses method to return the name of the team public String get... 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

Step: 3

blur-text-image

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

Business Statistics In Practice Using Data Modeling And Analytics

Authors: Bruce L Bowerman, Richard T O'Connell, Emilly S. Murphree

8th Edition

1259549461, 978-1259549465

More Books

Students also viewed these Programming questions

Question

Why are some fixed assets susceptible to theft?

Answered: 1 week ago

Question

why you want to attend graduate school in general;

Answered: 1 week ago

Question

What are the advantages of using a stem-and-leaf display?

Answered: 1 week ago