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)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.