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, 22.06.2019 20:50
What is the difference between windows 7 and windows 10?
Answers: 1
question
Computers and Technology, 23.06.2019 14:30
The option enables you to modify a slide element in most presentation applications.
Answers: 2
question
Computers and Technology, 24.06.2019 12:00
What is a sketch or blueprint of a web page that shows the structure (but not the detailed design) of basic page elements such as the logo, navigation, content, and footer?
Answers: 3
question
Computers and Technology, 24.06.2019 13:00
Append and make table queries are called queries. select complex simple action i think action
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
Mathematics, 01.10.2019 09:30
Questions on the website: 13722362