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

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

import java.util.Scanner; public class SciCalculator { public static void main(String[] args) { //Declare Scanner for user input Scanner scnr = new Scanner(System.in); //Declarations double currentResult = 0.0; double savedResult; int userInput; double firstOp; double secondOp; int exit = 0; int firstOpen = 0; int hideMenu = 0; double calculationsSum = 0.0; int calculationsNumber = 0; double calculationsAverage = 0.0; // Execute code while user doesn't press 0 (Exit) while (exit == 0) { // Show first "Current Result" if (firstOpen == 0) { System.out.println("Current Result:" + currentResult + "\n"); firstOpen++; } // Show menu depending on every specific case if (hideMenu == 0) { System.out.println("Calculator Menu\n---------------\n0. Exit Program\n1. Addition\n2. Subtraction\n3. Multiplication\n4. Division\n5. Exponentiation\n6. Logarithm\n7. Display Average\n"); } // Receive user's input (Enter Menu Selection) System.out.print("Enter Menu Selection:"); userInput = scnr.nextInt(); // Switch for every possible case of userInput. 0 is Exit, 1-6 are mathematical operations, and 7 is Display Statistics switch (userInput) { case 0: System.out.println("\nThanks for using this calculator.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture