Write a Java program. 1) Generate two random numbers between 2 and 10. 2) Ask user...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a Java program. 1) Generate two random numbers between 2 and 10. 2) Ask user to choose one operator from +, -, *,/ (note: / is an integer division) 3) Display Math formula using the numbers and the operator. (eg: 6 * 7 = ?) 4) Ask the user for an answer. If the user's answer is correct, display "You are a math genius! Bye." and terminate the program. If the user's answer is incorrect. Display "wrong answer!" and ask the user for the answer of the formular again. (Do not generate new numbers and formula.) 5) To calculate the answer, create a method and send/return the operator and two numbers. Like, . ● public static int math(String op, int a, int b) { int result = 0; if (op.equals("+") {result=...;} return result; } 6) you must pass 3 parameters (operator, first number, second number) to the math method and receive the result from the method. 7) Include appropriate program comments and formatting including: Your first and last name, a short description of the program's function and comments necessary to explain the operation of your program Write a Java program. 1) Generate two random numbers between 2 and 10. 2) Ask user to choose one operator from +, -, *,/ (note: / is an integer division) 3) Display Math formula using the numbers and the operator. (eg: 6 * 7 = ?) 4) Ask the user for an answer. If the user's answer is correct, display "You are a math genius! Bye." and terminate the program. If the user's answer is incorrect. Display "wrong answer!" and ask the user for the answer of the formular again. (Do not generate new numbers and formula.) 5) To calculate the answer, create a method and send/return the operator and two numbers. Like, . ● public static int math(String op, int a, int b) { int result = 0; if (op.equals("+") {result=...;} return result; } 6) you must pass 3 parameters (operator, first number, second number) to the math method and receive the result from the method. 7) Include appropriate program comments and formatting including: Your first and last name, a short description of the program's function and comments necessary to explain the operation of your program
Expert Answer:
Answer rating: 100% (QA)
Program name Math Challenge Author John Doe Description The program will generate two random numbers between 2 and 10 and ask the user to choose one operator from or integer division It will display a ... View the full answer
Related Book For
Posted Date:
Students also viewed these accounting questions
-
Write a Java program that simulates car racing, as shown in Figure 16.22(a). The car moves from left to right. When it hits the right end, it restarts from the left and continues the same process....
-
Write a Java program using NetBeans IDE or notepad that calculates the income tax . INTRODUCTION From 2009, people in the Strange country must pay income tax depended on the total amount he/she...
-
Write a Java program using NetBeans IDE or notepad that calculates the income tax . INTRODUCTION From 2009, people in the Strange country must pay income tax depended on the total amount he/she...
-
Evaluate the expression for the given value(s) of the variable(s). 4x - 7, x = 5/2
-
Part of your firm's evaluation of a supplier's performance is based on the degree to which it seamlessly delivers goods and materials. A recent complication for global suppliers is an initiative to...
-
On March 1, 2025, Bramble Corp. purchased land for an office site by paying $2730000 cash. Bramble began construction on the office building on March 1. The following expenditures were incurred for...
-
Suppose there are \(n\) assets. Asset \(i, i=\) \(1,2, \ldots, n\), has rate of return \(r_{i}\) over a single period. There is also a risk-free asset with rate of return \(r_{f}\). The log-optimal...
-
Does competition help or hurt the valuation of a business? Explain.
-
(1) Consider three qubit Fourier Transform. 1.a Write down 8x8 Quantum Fourier matrix (QFT) 1.b Apply the 8x8 Fourier matrix on the state (000). 1000) (1) 1. Apply the 8x8 Fourier matrix on the state...
-
In the circuit of Fig. 5.59 , calculate v o of v s = 2 V. 8 k2 2 k2 4 k2 4 k2 Vo Vs (+I) + I
-
A slitter for sheet sandpaper owned by Abbotsford Abrasives (AA) requires regular maintenance costing $7500 per year. Every five years it is over- hauled at a cost of $25 000. The original capital...
-
3. Consider the following pseudo-code in an imperative language: int x = 1, n = 1; function f () { int x = 3; function g (int c,d) { c = c-1; print (c,d,x,n); } /* end of g */ /* body of f */ g(x,x);...
-
What is the output of this C program? Explain. #include int main(void) { char x = 100; double y = 3.1415926; char *p = &x; double *q=&y; printf("p is %d, q is %d.", sizeof(p), sizeof(q)); return 0;
-
4. Suppose that a hard disk's heads are at cylinder 50 and requests have been queued for the following cylinders: 1, 57, 46, 104, 18, 60, 93, 32, 112. a. Give the order and the total number cylinders...
-
79. Prove that if p is a prime number and r is an integer with () 0
-
What is the complexity of given code segment below? public static void whoknows(int[][] arr) { for (int i = 0; i < arr.length; i++) { for (int j = 0; j
-
Today's world is very different from the world in which your grandparents lived. Tremendous advancements in technology have led to significant changes in the economy and in society. Imagine you are...
-
Is the modified 5-question approach to ethical decision making superior to the modified moral standards or modified Past in approach?
-
Write a method that reverses the sequence of elements in an array. For example, if you call the method with the array 1 4 9 16 9 7 4 9 11 then the array is changed to 11 9 4 7 9 16 9 4 1
-
Consider the following problem description: Employees receive their biweekly paychecks. They are paid their hourly rates for each hour worked; however, if they worked more than 40 hours per week,...
-
Use a stack to enumerate all permutations of a string. Suppose you want to find all permutations of the string meat. Push the string +meat on the stack. While the stack is not empty Pop off the top...
-
Many states have lotteries that involve the random selection of digits 0, 1, 2, ,
-
Is the distribution of those digits a normal distribution? Why or why not?
-
Birth weights in the United States are normally distributed with a mean (in grams) of 3420 g and a standard deviation of 495 g. If you graph this normal distribution, the area to the right of 4000 g...
Study smarter with the SolutionInn App