Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6689173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:29:19+00:00 2026-05-26T05:29:19+00:00

I am making a really basic calculator program (I’m fairly new to Java.) I’m

  • 0

I am making a really basic calculator program (I’m fairly new to Java.) I’m using the java.io.Console package for input from the command line, and my code looks like this:

import java.io.Console;

public class calculator {

public static void main(String args[]) {

Console console = System.console();
int exit = 1;


System.out.println("Calculator v1.0 by rulla101");
System.out.println(" ");

String inputselect = console.readLine("Type add, sub, mlt, or div to select operation: ");

if (inputselect == "add") {

//ADDING!!!
while(exit > 0) {

String input1a = console.readLine("Input number 1: ");
int a = Integer.parseInt(input1a);

String input2a = console.readLine("Input number 2: ");
int b = Integer.parseInt(input2a);

System.out.println("The answer is:");
System.out.println(a+b);

String exitstringa = console.readLine("Type 0 to exit, type 1 to add two more numbers: ");
int extseta = Integer.parseInt(exitstringa);

if(extseta == 0){
    exit--; 
    }
}

}
else if (inputselect == "sub") {

//SUBTRACTING!

while(exit > 0) {

String input1s = console.readLine("Input number 1: ");
int c = Integer.parseInt(input1s);

String input2s = console.readLine("Input number 2: ");
int d = Integer.parseInt(input2s);

System.out.println("The answer is:");
System.out.println(c-d);

String exitstrings = console.readLine("Type 0 to exit, type 1 to subtract two more numbers: ");
int extsets = Integer.parseInt(exitstrings); 

if(exitsets == 0){
    exit--;
}

}

}
else if (inputselect == "mlt"){

//MULTIPLYING!!

while(exit > 0) {

String input1m = console.readLine("Input number 1: ");
int e = Integer.parseInt(input1m);

String input2m = console.readLine("Input number 2: ");
int f = Integer.parseInt(input2m);

System.out.println("The answer is:");
System.out.println(e*f);

String exitstringm = console.readLine("Type 0 to exit, type 1 to multiply two more numbers: ");
int extsetm = Integer.parseInt(exitstringm); 

if(exitsetm == 0){
    exit--;
}
}
}
else if (inputselect == "div"){

//DIVIDING!!

while(exit > 0) {

String input1d = console.readLine("Input number 1: ");
int g = Integer.parseInt(input1d);

String input2d = console.readLine("Input number 2: ");
int h = Integer.parseInt(input2d);

System.out.println("The answer is:");
System.out.println(g/h);

String exitstringd = console.readLine("Type 0 to exit, type 1 to divide two more numbers: ");
int extsetd = Integer.parseInt(exitstringd); 

if(exitsetd == 0){
    exit--;
}
}
}
}
}

But when I try to compile the program, I get this:

/Users/ethan/javafolder/calculator/calculator.java:58: cannot find symbol
symbol  : variable exitsets
location: class calculator
    if(exitsets == 0){
       ^
/Users/ethan/javafolder/calculator/calculator.java:83: cannot find symbol
symbol  : variable exitsetm
location: class calculator
    if(exitsetm == 0){
       ^
/Users/ethan/javafolder/calculator/calculator.java:106: cannot find symbol
symbol  : variable exitsetd
location: class calculator
    if(exitsetd == 0){
       ^
3 errors


Done

I don’t understand…the variables in question aren’t previously defined or anything…and I’m pretty sure that they exist in the code…can anyone pick out the bug?

(p.s. I know it’s really bulky and bloated, and I could probably do it in half as many lines, but bear with me. Please.)

-rulla101

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:29:20+00:00Added an answer on May 26, 2026 at 5:29 am

    Look at three errors.

    int extsets = Integer.parseInt(exitstrings); 
    
    if(exitsets == 0){ //must be extsets
        exit--;
    }
    
    
    int extsetm = Integer.parseInt(exitstringm); 
    
    if(exitsetm == 0){  //must be  extsetm
        exit--;
    }
    
    
    int extsetd = Integer.parseInt(exitstringd); 
    
    if(exitsetd == 0){  //must be extsetd
        exit--;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting a really strange error when making a method call: /* input.cpp */
Questions Updated instead of making a new question... I really want to provide a
I'm making a fairly basic rails app and I was wondering what's the best
I am really new to Unit testing, and I have the following really basic
I think I am making a really basic mistake but after playing around for
I am making a basic quiz program, that when finished will allow the user
I'm making a really simple virtual host administrator in my office intranet (on a
One thing that's really been making life difficult in getting up to speed on
When making changes using SubmitChanges() , LINQ sometimes dies with a ChangeConflictException exception with
After making some changes in my models (eg. new field in a model and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.