subject

In this lab, you complete a partially written java program that includes a method that returns a value. the program is a simple calculator that prompts the user for two numbers and an operator ( +, −, *, /,or% ). the two numbers and the operator are passed to the method where the appropriate arithmetic operation is performed. the result is then returned to the main() method where the arithmetic operation and result are displayed. for example, if the user enters 3, 4, and *, the following is displayed:
3.00 * 4.00 = 12.00
// calculator. java - this program performs arithmetic, ( +. -, *. /, % ) on two numbers.
// input: interactive.
// output: result of arithmetic operation
import java. util. scanner;
public class calculator
{
public static void main(string args[])
{
double numberone, numbertwo;
string numberonestring, numbertwostring;
string operation;
double result;
scanner input = new scanner(system. in);
system. out. println("enter the first number: ");
numberonestring = input. nextline();
numberone = double. parsedouble(numberonestring);
system. out. println("enter the second number: ");
numbertwostring = input. nextline();
numbertwo = double. parsedouble(numbertwostring);
system. out. println("enter an operator (+*,/,%): ");

// call performoperation method here
result = performoperation(numberone, numbertwo, operation);

system. out. format("%.2f",numberone);
system. out. print(" " + operation + " ");
system. out. format("%.2f", numbertwo);
system. out. print(" = ");
system. out. format("%.2f", result);

system. exit(0);
} // end of main() method.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 17:20
The liang book has an example called which is a javafx application that reads the javabook database using a preparedstatement object. using it as a guide, create a similar application called findbooks. it will read a list of authors from the bookdb created in problem 1 and display them in a listview. if the user selects an author, it should display the author's book titles in a textarea.
Answers: 2
question
Computers and Technology, 23.06.2019 20:10
Leo is a recruitment executive for a large company. he has identified new labor resource requirements in both the marketing and production departments. what should be his first step in recruiting candidates for the positions? a. conduct background checks of candidates b. make job offers c. arrange interviews d. conduct reference checks e. place job ads on job sites
Answers: 1
question
Computers and Technology, 24.06.2019 12:00
How can we take picture in this app
Answers: 1
question
Computers and Technology, 24.06.2019 13:00
Ais a built in formula in spread spread a is any math process such as addition or subtraction. options are function and operation
Answers: 1
You know the right answer?
In this lab, you complete a partially written java program that includes a method that returns a val...
Questions
question
History, 10.12.2021 01:00
question
Chemistry, 10.12.2021 01:00
question
Mathematics, 10.12.2021 01:00
question
Chemistry, 10.12.2021 01:00
question
Mathematics, 10.12.2021 01:00
question
Advanced Placement (AP), 10.12.2021 01:00