7.25. LAB: Winning team (classes)
Given main(), define the Team class (in file Team. java). Fo...
![Computers and Technology](/tpl/images/cats/informatica.png)
Computers and Technology, 16.04.2020 05:17, xjdjsisi
7.25. LAB: Winning team (classes)
Given main(), define the Team class (in file Team. java). For class method getWinPercentage(), the formula is: teamWins / (teamWins + teamLosses)
Note: Use casting to prevent integer division.
Ex: If the input is:
Ravens
13
3
where Ravens is the team's name, 13 is number of team wins, and 3 is the number of team losses, the output is:
Congratulations, Team Ravens has a winning average!
If the input is Angels 80 82, the output is:
Team Angels has a losing average.
//Team. java file
public class Team {
// TODO: Declare private fields - teamName, teamWins, teamLosses
private String teamName;
private int teamWins;
private int teamLosses;
// TODO: Define mutator methods -
// setTeamName(), setTeamWins(), setTeamLosses()
// TODO: Define accessor methods -
// getTeamName(), getTeamWins(), getTeamLosses()
// TODO: Define getWinPercentage()
}
//WinningTeam. java file
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. setTeamName(name);
team. setTeamWins(wins);
team. setTeamLosses(losses);
if (team. getWinPercentage() >= 0.5) {
System. out. println("Congratulations, Team " + team. getTeamName() +
" has a winning average!");
}
else {
System. out. println("Team " + team. getTeamName() +
" has a losing average.");
}
}
}
![answer](/tpl/images/cats/otvet.png)
Answers: 2
Other questions on the subject: Computers and Technology
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 22.06.2019 14:00, GGerardi7552
What are procedures that keep a data base current
Answers: 1
![image](/tpl/images/cats/informatica.png)
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 02:00, ishmael9332
How are we able to create photographs differently than 100 years ago? explain your answer in relation to your photograph you selected.
Answers: 1
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 09:10, daedae11142
to change the number of rows and columns displayed by the excel object a. select the object and drag a size handle on the active object. b. deselect the object and drag a size handle of the object. c. deselect the object and drag a row or column divider of the object. d. select the object and drag a row or column divider on the active object.
Answers: 2
Do you know the correct answer?
Questions in other subjects:
![Konu](/tpl/images/cats/en.png)
![Konu](/tpl/images/cats/istoriya.png)
![Konu](/tpl/images/cats/mat.png)
Mathematics, 17.04.2020 18:15
![Konu](/tpl/images/cats/ekonomika.png)
![Konu](/tpl/images/cats/mat.png)
Mathematics, 17.04.2020 18:15
![Konu](/tpl/images/cats/mat.png)
Mathematics, 17.04.2020 18:15
![Konu](/tpl/images/cats/mat.png)
Mathematics, 17.04.2020 18:15
![Konu](/tpl/images/cats/mat.png)
Mathematics, 17.04.2020 18:15
![Konu](/tpl/images/cats/fizika.png)
Physics, 17.04.2020 18:15