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 7553755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:08:51+00:00 2026-05-30T11:08:51+00:00

This method is one of several. I was wondering if I am correct in

  • 0

This method is one of several. I was wondering if I am correct in the line here that says “if(dig1.contains() && dig2.contains() && res.contains())”. in the regex
1. I need to make sure that there is no letters in the string
2. I need to see if the sum of string1 and string2 add up to the third string. else return false. Thank you all for your help. This is so far what I have.

/**
  Returns true if the puzzle is solved.
  @return true if the puzzle has no letters and the 
  first two numbers add up to the third
*/
public boolean isSolved()
{
   String dig1=""+add1;
   String dig2=""+add2;
   String res=""+result;
   //String a1=""+dig1;
   if(dig1.contains("[^A-Z]") && dig2.contains("[^A-Z]") && res.contains("[^A-Z]")){
      int i=Integer.parseInt(dig1);
      int j=Integer.parseInt(dig2);
      int k=Integer.parseInt(res);

        if(i+j==k)
            return true;
        else
            return false;
     }
   else
       return false;

}

  • 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-30T11:08:52+00:00Added an answer on May 30, 2026 at 11:08 am

    Why would you use regular expressions for that? Integer.parseInt() will throw an exception if conversion is not possible. Just catch the exception and then you know that the strings contained something else than digits. Something along the line of this:

    public boolean isSolved() {
        try {
            int i = Integer.parseInt(dig1);
            int j = Integer.parseInt(dig2);
            int k = Integer.parseInt(res);
            return (i+j) == k;
        }
        catch (NumberFormatException e) {
            return false;
        }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

UIView has a setNeedsDisplay method that one can call several times within the same
Implemented a generic repository with several Methods. One of those is this: public IEnumerable<T>
I read in more than one website about this method of protecting forms: I
I modified one method of JQuery UI Resizable to achieve a centered resize. This
I have a create method in one controller and at the end of this
I have this code: s(x => x.Open()); s is a method which calls one
This is a continuation of the post How does one access a method from
This one has me stumped. I need to call an activity method from within
I have a method somewhat similar to the one written bellow(this is just a
I'm trying to load one page into another using the .load() method. This loaded

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.