Java
Answer: Hey! Dear student, kindly find your solution here. If you have any queries, feel free to ask me, would be very happy to resolve them. Thanks.
import java.io.*;
import java.lang.*;
class Scoreboard
{
public static int score,totalScore=0; //variable
static declared for using static methods
String str;
Scoreboard(int num) //constructor initailize score
variable
{
score = num;
}
public static void bonusPoints(int bonus) //bonnus
points method that assepts an integer
{
score = score+ bonus; //increase
the value of score variable
}
public static int addScores(int scores) //addScore
method to add score and return total
{
totalScore = scores*score;
return totalScore;
}
public static void main(String[]args) //main method
{
Scoreboard str = new Scoreboard(20); //call
constructor
str.bonusPoints(10); //call method
System.out.println(str.addScores(5)); //returninh
object compiler will write here str.toString() here
}
}
Get Answers For Free
Most questions answered within 1 hours.