Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Choose Your Operation (chapter 4) Write a program that uses a WidgetViewer object to do the following: Generate two random integers between 1 and 9

Choose Your Operation (chapter 4)

Write a program that uses a WidgetViewer object to do the following:

Generate two random integers between 1 and 9 (inclusive). Name one of them x, the other y. Display them to the user using JLabel objects.

Create a JLabel object displaying the text "Enter an operation number."

Create a JTextField for the user's input.

Create a JButton displaying the text "Press here when you've entered your operation." Use addAndWait to add it to the WidgetViewer object.

When the user clicks the JButton, evaluate operation in the following order to determine the one and only mathematical operation to perform on x and y. Use a JLabel to display the result.

If operation is between 1 and 10 inclusive, multiply x and y.

If operation is evenly divisible by 4, add y and x.

If operation is evenly divisible by 5, use floating point division to divide y into x.

If operation is an even number, use integer division to divide y into x.

If none of the other tests on operation apply, subtract x from y.

Note: Operation can be negative or zero. Note: Put a copy of WidgetViewer.java from the WidgetViewer primer in the folder along with your program.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions

Question

2. Why has the conflict escalated?

Answered: 1 week ago

Question

1. What might have led to the misinformation?

Answered: 1 week ago