SciCalculator.java - import java.util.Scanner public class...

This preview shows page 1 - 2 out of 2 pages.

import java.util.Scanner; public class SciCalculator { //This program displays the results of scientific calculator. public static void main(String[]args) { Scanner input = new Scanner(System.in); //Create a scanner for input //Declare Variables int choice = 1; double firstOperand, secondOperand; double result = 0.0; int count = 0; double sum = 0; while (choice != 0) // Loops that ends when user selects to exit. { if (choice >= 1 && choice <= 6) { //Display current result System.out.println("Current Result: " + result); System.out.println(); //Display the Calculator Menu System.out.println("Calculator Menu"); System.out.println("---------------"); System.out.println("0. Exit Program"); System.out.println("1. Addition"); System.out.println("2. Subtraction"); System.out.println("3. Multiplication"); System.out.println("4. Division"); System.out.println("5. Exponentiation"); System.out.println("6. Logarithm"); System.out.println("7. Display Average"); } //Let user select menu choice System.out.print("\nEnter Menu Selection: "); choice = input.nextInt(); //Special Cases if (choice == 7) { if (count == 0) { //Error message if the user selects 7 at the first time.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture