Hi, I am required to create a calculator program that will consist of a Arithmetic calculator, Area calculator, and volume calculator.
My problem area is the Area Calculator , I made it to only calculate fa square. But now I want to add in a Circle(radius * radius * pi) and Triangle(base * height/2)
And my second problem is that, every calculator (Area calculator) has to have the following features:
When a user presses "Y" Area calculator menu must be redrawn
When a user presses "N" Main menu of the calculator program must be redrawn.
Your help will be appreciated, please when replying try not to be too complex because I am a beginner and still trying to adjust to java. Thank you
import java.util.Scanner;
public class Calculator
{
* *public static void main(String[] args)
* *{
Without looking at your current code, I understand you need to test for the press of 'N'. I would use keyevent listner to run a continous loop to check for the pressing of N. This is done by using a new thread implementing the runnable class and overriding the run method. Also, you'll want to add a 1 millisecond sleep just so your program doesn't bottleneck all your resources at your loop's speed. Or, you could just add an if statement before every other one. Meaning E.G
Code:
if(UserInput.equals("N")) {
// deal with this however you need to (in your case just send to the top of the code for a
// repaint()
if(addition) {
Thank you. If I may ask I hav the following error it says "Creat a method arithmeticCalculator(int,int,java.lang.String) in calcultor" I n this of my code.
System.out.println("answer='arithmeticCalculator (num1, num2, arithmeticOperation));
Thank you. If I may ask I hav the following error it says "Creat a method arithmeticCalculator(int,int,java.lang.String) in calcultor" I n this of my code.
System.out.println("answer='arithmeticCalculator (num1, num2, arithmeticOperation));
Please help..
I am not sure what you mean. I can only guess from your code you posted, and what I can make out from here that your method arithmeticCalculator(int, int, String) isn't in your calculator class? Re-post your question, and your code in [/code] [/code] (put your code in between those tags, and remove the '/' slash from the first code tag). Then I'll be able to further help you.
When posting code please do as kolt007 has said and use code tags and please also remove all those * chars from the front of each line.
When posting error messages please post the whole error message and stack trace if any by cut and paste and not by retyping it.
My problem area is the Area Calculator , I made it to only calculate fa square. But now I want to add in a Circle(radius * radius * pi) and Triangle(base * height/2)
You should really have a separate class for each shape that all either extend a common class or implement a common interface. The root class/interface should define methods for getArea and getVolume.
And my second problem is that, every calculator (Area calculator) has to have the following features:
When a user presses "Y" Area calculator menu must be redrawn
When a user presses "N" Main menu of the calculator program must be redrawn.
Do you mean whenever they press one of the keys or do you mean if they enter Y or N in response to one or more of your questions? The first option is rather complex for a beginner.
Bookmarks