Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.Scanner; public class Team { / / Private fields private String name; private int wins; private int losses; / / Mutator methods public void

import java.util.Scanner;
public class Team {
// Private fields
private String name;
private int wins;
private int losses;
// Mutator methods
public void setName(String name){
this.name = name;
}
public void setWins(int wins){
this.wins = wins;
}
public void setLosses(int losses){
this.losses = losses;
}
// Accessor methods
public String getName(){
return name;
}
public int getWins(){
return wins;
}
public int getLosses(){
return losses;
}
// Calculate and return the win percentage
public double getWinPercentage(){
return (double) wins /(wins + losses);
}
// Print the team's standing
public void printStanding(){
double winPercentage = getWinPercentage();
System.out.printf("Win percentage: %.2f%n", winPercentage);
if (winPercentage >=0.5){
System.out.println("Congratulations, Team "+ getName()+" has a winning average");
} else {
System.out.println("Team "+ getName()+" has a losing average.");
}
}
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();
}
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Oracle PL/SQL Programming Database Management Systems

Authors: Steven Feuerstein

1st Edition

978-1565921429

More Books

Students also viewed these Databases questions

Question

what is the result when you restore down a window

Answered: 1 week ago

Question

Methods of Delivery Guidelines for

Answered: 1 week ago