11,Given a JPanel panel2 that sits in a JFrame. Create and add Go! and Stop! but
ID: 3542470 • Letter: 1
Question
11,Given a JPanel panel2 that sits in a JFrame. Create and add Go! and Stop! buttons to panel2.
12,Given the method average below, write an overloaded method average that has three double variables as its parameters and returns their average.
public static void double average(double score1, double score2)
{ return (score1+score2)/2; }
13,Given the following method header:
public String getStudent(int idNum)
write two overloaded method headers (don't write the body!)
14,Write a method named SetTemperature to compute and return the temperature which is equivalent to 50% of the current temperature value received.
15,What is the value of total displayed in showTotal, given the statement
Cashier abc = new Cashier( 15, 10);
using this definition:
public class Cashier {
int total;
public Cashier( int p, int q) {
int total = p * q;
}
public void showTotal() {
System.out.println("total="+total);
}
}
Explanation / Answer
11,Given a JPanel panel2 that sits in a JFrame. Create and add Go! and Stop! buttons to panel2.
JButton go = new JButton("Go!");
JButton stop = new JButton("Stop!");
panel2.add(go);
panel2.add(stop);
12,Given the method average below, write an overloaded method average that has three double variables as its parameters and returns their average.
public static void double average(double score1, double score2)
{
return (score1+score2)/2;
}
public static void double average(double score1, double score2,double score3)
{
return (score1+score2+score3)/3;
}
13,Given the following method header:
public String getStudent(int idNum)
write two overloaded method headers (don't write the body!)
public String getStudent(int idNum,string branch);
public String getStudent(int idNum,char gender);
14,Write a method named SetTemperature to compute and return the temperature which is equivalent to 50% of the current temperature value received.
public static double SetTemperature(double current_temperature)
{
return current_temperature*0.5;
}
15,What is the value of total displayed in showTotal, given the statement
Cashier abc = new Cashier(15,10);
using this definition:
public class Cashier {
int total;
public Cashier( int p, int q) {
int total = p * q;
}
public void showTotal() {
System.out.println("total="+total);
}
}
total=0;
as we are not intializing total in constructor.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.