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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:08:59+00:00 2026-06-13T06:08:59+00:00

Hello guys I’am beginner of the Java and my English is not good, i

  • 0

Hello guys I’am beginner of the Java and my English is not good, i hope you will understand my problem:

public static void main(String[] args) {

    int i, a, b, c, d, yil = 1999, rt = 0;


    do{
            //loop searching for 1976
            for( i = 1900; i < 2000; i++){
            //separate "i" to the digits
            a = i / 1000;
            b = i % 1000 / 100;
            c = i % 1000 % 100 / 10;
            d = i % 1000 % 100 % 10;
            rt = a + b + c + d;
            }}
            //while rt=23 and i=1976 equation will be correct then exit the loop and print the 1976.
            while( rt == yil - i );
        System.out.println("Yıl = " + i );

}

But when i run the program it always show 2000 not 1976.

  • 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-13T06:09:01+00:00Added an answer on June 13, 2026 at 6:09 am

    Your messed increments may hide it, but you have no way out of your for loop. It always goes to the end, that is i=2000.

    for( i = 1900; i < 2000; i++){
       ... // no break in there
    }
    ...
    System.out.println("Yıl = " + i );
    

    There is no reason for having two loops in your case. It seems that what you want is

            int i, a, b, c, d, yil = 1999, rt = 0;
            //loop searching for 1976
            for( i = 1900; i < 2000; i++){
                //separate "i" to the digits
                a = i / 1000;
                b = i % 1000 / 100;
                c = i % 1000 % 100 / 10;
                d = i % 1000 % 100 % 10;
                rt = a + b + c + d;
                if (rt==yil-i) break;
            }
            System.out.println("Yıl = " + i );  }
    

    This outputs

    Yıl = 1976
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello guys I'am beginner of the Java and i've got some problems with array&arraylist.
Hello guys I'm stuck with this weird problem , asp:HyperLink control is not being
Hello guys I have a problem with my application involving Lucene java library and
Hello guys can you please help me with this problem. When a simple image
Hello guys i have a problem streaming PDF files with php, i'm using this
hello guys i'm not sure if the title is descriptive enough.what i mean is
Hello guys am having a problem with downloading modules. Anytime i try to download
Hello guys i have a little problem i get an error: File C:\Users\kokki\Desktop\gb1\main.py, line
Hello guys maybe you maybe can help . here is my problem For example
Hello guys i have a small problem at my console application i have a

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.