using IJVM..can anybody help me in this question
User should be prompted to enter two non-negative numbers (say, a and b where a >0 and b > 0) line by line and then press the enter key. Your program should calculate and display the following for these numbers (see sample output below): Sum (a + b) Difference (a - b or b - a, whichever gives a positive value) Product (a x b) Power (ab)
OUTPUT Num1: 2 Num2: 10 Sum = 12 Difference = 8 Product = 20 Power = 1024 Num1: a Invalid Number Num1: x End of program
Implement the above in a loop so that the user is prompted to keep entering two numbers and the program produces the required results for each set of numbers until user enters ââ?¬Å?xââ?¬Â? (character x) which should halt (end) the program.
�· Validate your inputs to only accept non-negative numbers as input (i.e. n â�¥ 0). Hence, if user enters characters like negative numbers, alphabets or any other character; your program should display some appropriate error message and prompt for another valid number.
�· Use appropriate subroutines (functions/methods) in your program. For example, each mathematical operation/function could be in a subroutine.
�· Write appropriate comments and use good programming techniques in your code where possible.
Ads