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

  • Home
  • SEARCH
  • 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 8798337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:04:31+00:00 2026-06-14T00:04:31+00:00

I am learning Java and just been working on creating a little calculator. I

  • 0

I am learning Java and just been working on creating a little calculator. I am writing one what will allow me to put any number of digits in until I press an equals sign at which point I want the calculator to display the total.

I think that there is a problem with the scanner as while debugging I only get as far as Scanner input = new Scanner (System.in): In the debugger it say Source not found. This is really strange especially as I am using two Scanners the other class within the same project with no problems at all. As you can tell I used to have 2 scanners in this piece but I read that this should not work so I am now using one. Here is the code…

package Calculator;

import java.util.Scanner;

public class Calculator3 {

    public static void main(String[] args) {

        Scanner input = new Scanner (System.in);
    //  Scanner opin = new Scanner (System.in);     
        String operative = input.next();        
        double numb = input.nextDouble();
        int answer = 0;
        int calc = 1;

        System.out.print("#######################################" + "\n");             
        while (operative.equalsIgnoreCase("="))
            {
            System.out.print("Interger " + calc + " :");
            System.out.print("Type your Operative :");
            if (operative.equals("+")) 
                answer += numb;
            {
                if (operative.equals("-")) 
                    answer -= numb;
                    {
                        if (operative.equals("/")) 
                            answer /= numb;
                            {
                                if (operative.equals("*")) 
                                    answer *= numb;
                                {
                                }
                            }
                    }
            }
        calc += 1;  
            }
        System.out.print("#######################################" + "\n");     
        System.out.println("Your answer is: " + answer + ".");
}
}
  • 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-06-14T00:04:32+00:00Added an answer on June 14, 2026 at 12:04 am

    The issue with your code is that the operative is not updated, and probably not = after the first read. Because of this your loop will not exit and the print statement will not be reached. Following your logic, you need to add read statements in your loop. Also I suggest using a switch, will make your more readable and easy to maintain.

    Also note that while debugging you will get “Source not found” for classes for which your debugger is not able to detect the source. Probably your JDK configuration is missing the source entry. See this answer for details on what you need to check to fix your JDK config, if you are using Eclipse.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been writing Java web (JSF, Struts, JSR168) apps for a number of years.
We've just started learning Java for my degree and I've been given a folder
Been learning Android for two months now,Have a little java knowledge but I don't
I'm just beginning to learn Java and I have been very frustrated about learning
I've been learning Java these days and what I've read just is Be careful
As someone learning Java from scratch, who knows a little Python, I have been
I am learning Java and just found that the Interface can have fields, which
We are just learning Java/Selenium as our QA is moving towards automation. I am
Total noobie question here. I'm just learning Java, and studying passing arguments to functions.
I've just started learning Java (about a week ago) and the last few days

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.