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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:40:38+00:00 2026-05-26T07:40:38+00:00

I ran in to a small problem while working on my assignment. Basically I’m

  • 0

I ran in to a small problem while working on my assignment. Basically I’m making a small program that asks the user for 3 letters and compares them to 3 letters that are coded in. Then the program is supposed to compare the 3 letters and if they’re the same then print true. Thus far I’ve been able to make it without problems using compareTo, but now the tricky part is that I need to add a “tolerance” to the program (which I have) but the tolerance is supposed to loop back from Z to A. So if tolerance is 3 and the user inputs X Y Z (when it really is A B C) it should still print out true.

NOTE: the Tolerance will not go above 3. ALSO, We shouldn’t use Arrays.

Any ideas how I can accomplish this? If it’s complicated to understand what I’m asking please post and I’ll try to clarify it 🙂

Thanks

EDIT: basically this is the code that compares the tolerances

        if ((a1.compareTo(d1) <= tolerance) && (a1.compareTo(d1) >= negTolerance) 
        && (b1.compareTo(e1) <= tolerance) && (b1.compareTo(e1) >= negTolerance) 
        && (c1.compareTo(f1) <= tolerance) && (c1.compareTo(f1) >= negTolerance))
    {
        open = true;
    } else open = false;

where a1 – c1 are pre inputed characters and d1-f1 are user entered. tolerance is also user entered as an integer between 1 and 3

  • 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-26T07:40:39+00:00Added an answer on May 26, 2026 at 7:40 am

    Since it’s a homework assignment, I won’t give you the full answer, but I’ll give you a hint. You want to look at the character codes (ASCII) for the letters. This will let you solve the tolerance problem. You might also have to do some magic with % (modulus) to handle the looping back of Z to A.

    EDIT

    If you cannot use the ASCII values, the return value of compareTo will help you, but keep in mind that that comparing A to Z and Z to A will give you -25 and 25 respectively. This is where the % operator will help you.

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

Sidebar

Related Questions

Just started working with android and ran into a small problem. I am have
In my program, I ran into a problem writing a small number to a
I ran across a small framework some time back that someone put together for
I ran into the problem that my primary key sequence is not in sync
I've ran into one small problem. I am dynamically generating some controls and place
I'm doing a project for a comapny and I ran into a small problem
I've just began learning Python and I've ran into a small problem. I need
I've worked on a program that uses databases to send small messages from one
I ran into an interesting behavior recently. It seems that if I override .equals()
I have written a small program using Borland's C++ builder, and along the way,

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.