#program hep

1 messages ยท Page 1 of 1 (latest)

unkempt willowBOT
#

<@&987246399047479336> please have a look, thanks.

unkempt willowBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

#

Here is an AI assisted attempt to answer your question ๐Ÿค–. Maybe it helps! In any case, a human is on the way ๐Ÿ‘. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#

ass method getWinPercentage(), the formula is:
(double) wins / (wins + losses).

Here is the updated code for the Team class:

public class Team {
    private int wins;
    private int losses;
    
    public Team(int wins, int losses) {
        this.wins = wins;
        this.losses = losses;
    }
    
    public double getWinPercentage() {
        return (double) wins / (wins + losses);
    }
}

In the main() method, you can create an instance of the Team class and call the getWinPercentage() method to calculate the win percentage. Here's an example:

public static void main(String[] args) {
    Team team = new Team(10, 5);
    double winPercentage = team.getWinPercentage();
    
    System.out.println("Win Percentage: " + winPercentage);
}

Output:
Win Percentage: 0.6666666666666666

wide mason
#

Given main(), define the Team class (in file Team.java). For class method getWinPercentage(), the formula is:
wins / (wins + losses). Note: Use casting to prevent integer division.
For class method printStanding(), output the win percentage of the team with two digits after the decimal point and whether the team has a winning or losing average. A team has a winning average if the win percentage is 0.5 or greater.
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();

}
}
public class Team {
private String teamName;
private int teamWins;
private int teamLosses;
//private double doubleWins = teamWins;
//private double doubleLosses = teamLosses;
private double winLossRate;

// TODO: Define mutator methods -
// setName(), setWins(), setLosses()
public void setName(String name)
{
teamName = name;
}

public void setWins(int wins)
{
teamWins = wins;
}

public void setLosses(int losses)
{
teamLosses = losses;
}
// TODO: Define accessor methods -
// getName(), getWins(), getLosses()
public String getName()
{
return teamName;
}

public int getWins()
{
return teamWins;
}

public int getLosses()
{
return teamLosses;
}

// TODO: Define getWinPercentage()
public double getWinPercentage()
{
winLossRate = (double) teamWins / (teamWins + teamLosses);
}

// TODO: Define printStanding()
public void printStanding()
{
System.out.println(teamName);
System.out.println(winLossRate);
//System.out.println();
}

}