answersLogoWhite

0

How do you create a java calculator?

User Avatar

Anonymous

12y ago
Updated: 10/18/2022

I made this in bluej(Free Java compiler)

import java.io.*;

import java.util.*;

public class Calculator

{

public static void main(String args[])

{

System.out.println("Make your arithmetic selection from the choices below:\n");

System.out.println(" 1. Addition");

System.out.println(" 2. Subtraction");

System.out.println(" 3. Multiplication");

System.out.println(" 4. Division\n");

System.out.print(" Your choice? ");

Scanner kbReader = new Scanner(System.in);

int choice = kbReader.nextInt();

if((choice<=4) && (choice>0))

{

System.out.print("\nEnter first operand. ");

double op1 = kbReader.nextDouble();

System.out.print("\nEnter second operand.");

double op2 = kbReader.nextDouble();

System.out.println("");

switch (choice)

{

case 1: //addition

System.out.println(op1 + " plus " + op2 + " = " + (op1 + op2) );

break;

case 2: //subtraction

System.out.println(op1 + " minus " + op2 + " = " + (op1 - op2) );

break;

case 3: //multiplication

System.out.println(op1 + " times " + op2 + " = " + (op1 * op2) );

break;

case 4: //division

System.out.println(op1 + " divided by " + op2 + " = " + (op1 / op2) );

}

}

else

{

System.out.println("Please enter a 1, 2, 3, or 4.");

}

}

}

User Avatar

Matteo Kunze

Lvl 10
3y ago

What else can I help you with?

Related Questions

How do you program a reverse auto loan calculator in JAVA?

In order to program a reverse auto loan calculator in JAVA, you are going to need a lot of experience with JAVA. There are online tutorials that can help you set up with fundamentals of JAVA so that you will be able to create almost any basic program you want.


Download code for scientific calculator in java?

yes


Report on calculator project in core java?

yes


Can you create a constructor for an interface in java?

NO, we cannot create a contructor for an interface in java.


How do you create setup of core java project?

how to create setup file in core java


Where can I find an ira calculator online?

www.dinkytown.net/java/RothIRA.html is a good one


What is the best compiler can be used to create Java programs?

A Java compiler.


Who create Java and when?

James Gosling and his team at Sun Microsystems developed Java in the early 1990s. The language was officially released to the public in 1995. Java was designed to be simple, secure, portable, and object-oriented, making it one of the most popular programming languages in the world.


Where can I find an investment return calculator that meets my needs?

There are several options available for you. You can obtain an investment calculator at the following website: www.dinkytown.net/java/InvestmentReturn.html.


What three objects are necessary to create a GUI in Java?

A computer, keyboard and Java compiler.


How do you create master page in jsp?

how to create a master page in java


What are the feature's of the Java 'this' installation package?

The Java 'this' installation package allows one to create installation programs for their Java based applications. One can download the program from Java.