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

GUI for Math Operations ( In JAVA using WidgetView , simplest beginner form) Wri

ID: 3887667 • Letter: G

Question

GUI for Math Operations( In JAVA using WidgetView , simplest beginner form)


Write a program that asks the user for 2 integer numbers and displays those numbers added, subtracted, multiplied, divided and modulo.

Use a WidgetView object.

In your GUI, display a label containing instructions to the user such as "Enter two ints and I'll perform math operations on them."

Create two text fields for the user to enter the numbers.

Use a button for the user to indicate that he has entered the numbers.

When the user clicks the button, display labels showing the results of each operation with an indication of the operation performed, such as "adding 7 and 8 is 15."

Explanation / Answer


If not using integers (or whatever), I advise to use 'printf' because you can form the output.

A different way to display numbers is:
System.out.printf("number: %d", num1);

The last example would be:



That is, the '%d' is replaced with the value of num1 or num2 or the other operation/variable.
To replace float variable values, use %f.

With multiplication and division of decimals, it can get messy because of the point. So let us add that '.2' between '%' and 'f', leaving %.2f .
This means that after the decimal point, print only two decimals. See: