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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:08:21+00:00 2026-06-10T12:08:21+00:00

So I’m a first year comp sci student, and I have to create a

  • 0

So I’m a first year comp sci student, and I have to create a program which takes an array scrambles it, and then sorts it again. I’ve pretty much got it working, but for some reason, one of my while loops will not work and is completely bypassed. I’m really new at this, so all help is appreciated. I have sort, and print working, scramble is just giving me some trouble.

import java.io.*;
import java.util.Random;
public class Driver03
    {
     public static void main(String[] args)
      {
        int[] array = {100, 101, 102, 103, 104, 105, 106, 107, 108, 109};
        print(array);
        array = scramble(array);
        print(array);
        array = sort(array);
        print(array);
      }
      public static void print(int[] apple)
        {
            for(int x = 0; x < apple.length; x++){
                System.out.println(apple[x]+"");
                }
        }
      public static int max;
      public static int maxIndex;
      public static int temp;
      public static int[] sort(int[] grape)
        {
            for(int y = grape.length; y > 0; y--){
            for(int x = 0; x < y; x++)
              if (x==1){
                    if (grape[x] > grape[x-1]){
                        max = grape[x];
                        maxIndex = x;
                        }
                    else{
                        max = grape[x-1];
                        maxIndex = x - 1;
                        }
                    }
                 else{
                    if (grape[x] > max){
                        max = grape[x];
                        maxIndex = x;
                        }
                    }
                 temp = grape[maxIndex];
                 grape[maxIndex] = grape[y-1];
                 grape[y-1] = temp; 
                }
            return grape;
        }
     public static int temp1;
     public static boolean t;
     public static boolean u;
     public static int[] numbers;
     public static int[] tangerine;
     public static int[] scramble(int[] orange)
        {
        numbers = new int[10];
        tangerine = new int[10];
        Random rand=new Random();

        for(int x = 0; x < orange.length; x++){
            t=false;
            while (t=false){ //For some reason being bypassed
                int randn = rand.nextInt(9);
                for(int y = 0; y < numbers.length; y++){
                    if (numbers[x]==randn)
                        u = true;
                    }
                if (! (u==true))
                    {
                    numbers[randn] = randn;
                    tangerine[randn] = orange[x];
                    t = true;
                    }
                }           
            }
          return tangerine;
        }

    }
  • 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-10T12:08:23+00:00Added an answer on June 10, 2026 at 12:08 pm

    t=false assigned the value false to t and evaluates to the new value. Thus you’ve just written while (false).

    When comparing equality you need to use ==.

    However, in the case of booleans, it’s much better style to just use while (!t). This is both more readable and less likely to go wrong due to missing a second =.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a text area in my form which accepts all possible characters from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,

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.