answersLogoWhite

0

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

Wiki User

14y ago

What else can I help you with?

Related Questions

Is it possible to draw in java without using applet?

Yes it is possible to draw in java by using AWT package. or by using javax package.


Difference between awt and java script?

AWT is a Java package for creating graphical user interfaces. JavaScript is a completely unrelated programming language.


Which are the AWT components in Java?

AWT stands for Abstract window toolkit. AWT gives us the components using which we can create User- Interface based applications in java. Some of the components are: a. Frame b. Panel c. Window d. CheckBox e. RadioButton f. Button g. TextBox h. TextArea i. Etc


What is the methods with the parameters of an AWT?

AWT (Abstract Window Toolkit) is a top-level Java package. Listing out the hundreds or thousands of methods would be a waste of effort. See the related link below for the Java documentation on the AWT package.


What do you mean by AWT?

AWT stands for Abstract Window Toolkit It contains the list of java classes &amp; packages that can be used to create UI based applications using java. Some components available are: * button * text field * text area * scroll bar * etc...


What is awt in java explain its features?

awt contains all the graphical features of java, including many different elements to create an acceptable and usable GUI for applications easily. such as buttons, sliders and text areas.


Why is itemstatechanged method called thrice on changing an item in java swings?

http://docs.oracle.com/javase/7/docs/api/java/awt/event/ItemListener.html#itemStateChanged%28java.awt.event.ItemEvent%29 "http://docs.oracle.com/javase/7/docs/api/java/awt/event/ItemListener.html#itemStateChanged%28java.awt.event.ItemEvent%29"


What are Awt Components?

AWT stands for Abstract window tootlkit . Abstract window Toolkit provides a standard application programming interface for writing graphical user interfaces in java.


What does someone use AWT for?

AWT (Abstract Window Toolkit) is Java's original widget program allowing webmasters to add outside widgets to their sites for users to interface between them and other sites.


Which is best institute to learn java and mainframe course in pune?

Virtual Vision Institute in Pune is the best for Java Course. You get best training regarding Java interfaces, Java Packages, Java AWT & SwingsFor More Information you can visit our websitevirtualvision.in/core-java/Contact Number : 9766119340


What are the types of java program?

There are many different types of Java programs. a. Simple Standalone applications - They are simple java programs that have a bunch of classes and have a starting class that has a main method b. UI Based Applications - These are UI based applications built using AWT or Java Swings c. J2EE Web Applications - These are web based applications that can be run in a web browser. They are coded using technologies like servlets, jsp, hibernate, spring etc.


What is awt in java?

java.awt is a standard package of Java. It is a GUI(Graphical User Interface) package, which has classes in it such as Frame, Panel, and Button. Most of the package was later replaced with the javax.swing package, which has most of the same classes, only with a J prepended to them (JFrame, JPanel, JButton). However the java.awt package still includes some event handlers that are considered standard in java (java.awt.event).