***In Java*** Write a class that defines these two types of methods: public stat
ID: 3881038 • Letter: #
Question
***In Java***
Write a class that defines these two types of methods:
public static int record(int w, int l, int t)
Have this method return the number of standings for the "record", based on the parameters. The number of points is equal to: (wins * 2) + ties.
For the second method:
public static void booTeam(String name)
For this method, it should print out "Booooooo" if name is equal to "Cowboys". If it's NOT equal to "Cowboys", the method should print out "Go name" (where name is the parameter's value).
Note: You don't need to take in any user input, just looking for the methods.
Explanation / Answer
class Test
{
public static void main (String[] args)
{
System.out.println("Record : "+record(5,4,1)); // function calls
booTeam("Cowboys");
}
public static int record(int w, int l, int t)
{
return (w * 2) + t;
}
public static void booTeam(String name)
{
if(name.equals("Cowboys")) //equals method is used to compare Strings
System.out.println("Booooooo");
else
System.out.println("Go "+name);
}
}
Output:
Record : 11
Booooooo
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.