Couldnt figure out where to post this... So here i am.
I need help figuring out what to do next.
this is suppose to be a calculator that works with the current value, basically keeping the current value and changing it with each option from the menu.
My Professor states that we need the following fields and methods
fields :
private double currentValue
Methods:
public static int displayMenu()
public static double getOperand(String prompt)
public double getCurrentValue()
public void add(double operand2)
public void subtract(double operand2)
public void multiply(double operand2)
public void divide(double operand2)
public void clear()
Im lost, and i just need alittle guidance in where to go next, or tell me what i am doing wrong.
when i end bracket the main method, i seem to get an error on everything else... So i just need some guidance.
I havent gotten to the implementing the quit function yet. but that i understand how to do.
import java.util.Scanner; public class MemoryCaluclator { private double currentValue; public static void main(String[] args){ Scanner stdIn = new Scanner(System.in); int getMenuOption = displayMenu(stdIn); double operand2 = getOperand(stdIn); } public static int displayMenu(Scanner stdIn) { int getMenuOption = stdIn.nextInt(); if (getMenuOption > 1 || getMenuOption < 6){ System.out.println("Menu:"); System.out.println("1. Add"); System.out.println("2. Subtract"); System.out.println("3. Multiply"); System.out.println("4. Divide"); System.out.println("5. Clear"); System.out.println("6. Quit"); System.out.println("What would you like to do?"); } else { System.out.println("Please Choose a Menu Option."); } return getMenuOption; } public static double getOperand(Scanner stdIn){ System.out.println("What is the Second Number?:"); double operand = stdIn.nextDouble(); return operand; } public double getCurrentValue( Scanner stdIn) { return currentValue; } public void add(double operand2){ double answer = currentValue + operand2; System.out.println("The Current Value is" + answer); } public void subtract(double operand2){ double answer = currentValue - operand2; System.out.println("The Current Value is" + answer); } public void multiply(double operand2){ double answer = currentValue * operand2; System.out.println("The Current Value is" + answer); } public void divide(double operand2){ double answer = currentValue / operand2; System.out.println("The Current Value is" + answer); } public void clear(){ currentValue = 0; return; } }