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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:47:39+00:00 2026-05-28T03:47:39+00:00

My assignment says to do the following: Search2: Search for a solution to x*x

  • 0

My assignment says to do the following:
Search2: Search for a solution to x*x + y*y – 12x -10y + 36 = 0. Search from 0 to 10 in both x and y, searching every y value before moving to the next x. Print the first three solutions found. (Note – a labelled break is handy here!)

I can’t figure out the logic for this. I think I have to use more than 2 loops but not sure.
This is what I have so far (It just repeats (6,0)):

for (int j = 0; j <= 10; j++) {
    for (int i = 0; i <= 10; i++) {
        while (((i * i) + (j * j) - (12 * i) - (10 * j) + 36) == 0) {
            System.out.println("(" + i + ", " + j + ")");  
        }  
    }  
}  

UPDATE
Here is the solution:

    int t = 0;

    for (int i = 0; i <= 10; i++) {
        if (t == 3) {
            break;
        }
        for (int j = 0; j <= 10; j++) {
            if (((i * i) + (j * j) - (12 * i) - (10 * j) + 36) == 0) {
                System.out.println("(" + i + ", " + j + ")");
                t++;
            }
        }
    }
  • 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-28T03:47:40+00:00Added an answer on May 28, 2026 at 3:47 am

    Not a bad attempt. Because you’re so close, I’ll show you a working solution. Basically, you need to do three things:

    1. Change while to if
    2. Use a variable to count the number of times you find the solution, so you can stop at three
    3. Add a label so you can break out of the outer loop from within the inner loop

    I also recommend you use variable names the same as the problem – ie x and y – for clarity.

    int count = 0;
    outerLoop:
    for (int y = 0; y <= 10; y++) {
        for (int x = 0; x <= 10; x++) {
            if (x * x + y * y - 12 * x - 10 * y + 36 == 0) {
                System.out.println("(" + x + ", " + y + ")");  
                if (++count == 3)
                    break outerLoop;
            }
        }
    }
    

    When executed, this code produces:

    (6, 0)
    (3, 1)
    (9, 1)
    

    Sorry for spoon-feeding you, but part of the lesson here is good coding style and practice.

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

Sidebar

Related Questions

The assignment in the Big Nerd Ranch Guide says: Silver Challenge: Another initializer Create
The assignment at my first year uni computing course says my program should read
I have to do an assignment for my class and it says not to
My understanding of C# says (thanks to Jeff Richter & Jon Skeet) that assignment
Assignment: Write a C++ program to read the menu information from menu.txt. First letter
This is a problem on Asymptotic Notation from the assignment of MIT OpenCourse Introduction
I am trying to complete my assignment.which says In a Distance class create an
This is an assignment that I've been given, it says that if an hash-set
I was reading an algorithms book which had the following algorithm for binary search:
I have the following function but my compiler (VS2003) says that the assignement T

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.