67 257
Assignments Done
99,3%
Successfully Done
In November 2018

Answer to Question #63838 in Java | JSP | JSF for Damien Rice

Question #63838
You are now going to write the printSign() method. Your method must: use the public access modifier
take a single formal argument of type double
return no value, i.e. have a void return type
use the divide() method to find the result of attempting to divide the argument by the current value of divisor and store the result in a suitable local variable called quotient
l using nested selection statements, print out to the Display Pane 'The quotient is zero', 'The quotient is positive', or 'The quotient is negative', depending on whether quotient is zero, greater than zero, or less than zero, , respectively.
Write the method printSign() as specified above. You should include an appropriate comment before the method header describing what the method does in terms of its argument and the output in the Display Pane.
Expert's answer
public class Main {
public double currentValueOfDivisor;

public double divide(double v1, double v2) {
return v1 / v2;
}

/**
* Method to find the result of attempting to divide
* the argument by the current value of divisor and
* store the result in a suitable local variable
* called quotient
* print out to the Display Pane 'The quotient is zero',
* 'The quotient is positive', or 'The quotient is
* negative', depending on whether quotient is zero,
* greater than zero, or less than zero, respectively.
* @param value dividend
*/
public void printSign(double value) {
double quotient = divide(value, currentValueOfDivisor);
if (quotient > 0)
System.out.println("The quotient is positive");
else if (quotient < 0)
System.out.println("The quotient is negative");
else
System.out.println("The quotient is zero");
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions