Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create an application class whose main() method holds two numeric variables. Pro

ID: 3565829 • Letter: C

Question

Create an application class whose main() method holds two numeric variables. Prompt the user for values for the variables. In a loop that continues while the returnded value is N, pass both variables to a method that determines whether the first number is larger then the second and appropriately returns a character Y or N. After the method returns Y, pass the two numbers to a method named difference() that computes the difference between its two parameters and displays the result. **MUST BE IN PSEUDOCODE

Explanation / Answer

BEGIN main()

     int x, y, result

    char c= ‘N’

    WHILE c == ‘N’

          output “Enter the value for x:”

          input x

          output “Enter the value for y:”

          input y

          c = call computeGreaterValue(x, y) method that returns a

character

          IF c == ‘Y’

              result = call difference(x,y) method that returns an integer

              output “The difference between x and y value is:”

              output result

          ENDIF

     ENDWHILE

END main

//computeGreaterValue that returns a character

char computeGreaterValue(int x, int y)

     char ch = ‘N’

     if(x > y)

          ch = ‘Y’

     else

          ch = ‘N’

return ch

//difference method that returns an integer

int difference(int x, int y)

     return (x-y)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote