Question
Using Bluefish, create a Java file named Calc.java in your Working Directory. Create a public class named Calc. Request a double precision number from the
Using Bluefish, create a Java file named Calc.java in your "Working Directory".
Create a public class named Calc.
Request a double precision number from the user.
Request a second double precision number from the user.
Request an operation from the user. Valid inputs will be {+ - * /} - the program should display an error if an invalid operator is provided by the user.
Perform the requested calculation on the two numbers, and display the double precision answer on the screen.
Compile your program, and make sure that it works as expected.
Hint 1: Use a switch statement to select the operation to perform.
This is what I have so far....
import java.util.Scanner;
class calc{ public static void main(String args []){ Scanner calculation = new Scanner(System.in); double num1,num2,answer; System.out.println ("Enter your first number:"); num1 = calculation.nextDouble(); System.out.println("Enter your second number:"); num2 = calculation.nextDouble(); answer = ; System.out.println(answer); }
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started