Ask your own question, for FREE!
Mathematics 22 Online
OpenStudy (yumi):

Java Algorithm. PLEASE HELP!!!

OpenStudy (yumi):

I have the code completed, just need help with the algorithm (flowchart)

OpenStudy (yumi):

public class Chpt7_Project { public static void main(String[] args) { int[] a=new int[10]; int b; for(int i=0; i < 10 ; i++) { b=(int)(Math.random()*100+1); //Generate 10 random integer numbers between 1 and 100, //System.out.print("Random Number ["+ (i+1) + "] : " +b ); a[i]=b; } System.out.print("unsorted list is: "); for(int j=0; j < 10 ; j++) System.out.print(a[j] + " "); bubbleSort(a); System.out.print("\nsorted list is: "); for(int q=0; q < 10 ; q++) System.out.print(a[q] + " "); } private static void bubbleSort(int[] a) { int temp; for (int k = a.length - 1; k > 0; k--) { for (int p = 0; p < k; p++) { if (a[p] > a[p + 1]) { temp = a[p]; a[p] = a[p + 1]; a[p + 1] = temp; } } } } }

OpenStudy (karim728):

you post a code with no comments or a description explaining what you want to achieve?

OpenStudy (yumi):

what??

OpenStudy (mhchen):

So you want to make a flowchart? With the 4 symbols right?

OpenStudy (yumi):

yes! @mhchen

OpenStudy (mhchen):

okay that's quite a bit of code so let me read it real quick

OpenStudy (yumi):

okay! Thanks

OpenStudy (mhchen):

I'm gonna be using www.draw.io btw.

OpenStudy (yumi):

ive never used that before

OpenStudy (mhchen):

It's okay. I'll screenshot it or share with google drive once I'm done.

OpenStudy (518nad):

okay the code looks right

OpenStudy (yumi):

i know the code is, just need help with the algorithm

OpenStudy (518nad):

http://prntscr.com/d9rua4

OpenStudy (518nad):

it should look something like this

OpenStudy (518nad):

thats not exactly what ur doing just a sample, if u have some flowchat uve already made i can look to see what ur missing

OpenStudy (mhchen):

hang on I'm almost done

OpenStudy (mhchen):

nad just shhhh

OpenStudy (518nad):

okay but you should let her do it, I know its fun to just make them ourselves but =.=

OpenStudy (mhchen):

I wonder what happens if I share an 'editable' thing on google drive xD

OpenStudy (518nad):

if we do this for her now, she will never know the JOY, do you want to deprive her of THE PURE JOY OF FLOW CHARTING

OpenStudy (518nad):

Lol

OpenStudy (mhchen):

.-. I hate flowcharting

OpenStudy (yumi):

can either help me or no?

OpenStudy (mhchen):

Actually I don't trust you nad.

OpenStudy (518nad):

just take a screenshot

OpenStudy (mhchen):

:b, Yumi check pms.

OpenStudy (yumi):

Thank You!

OpenStudy (mhchen):

Of course I'm probably not guaranteed to be right, cuz that loop thing was weird.

OpenStudy (518nad):

if u take a screenshot.. i can check it -_-

OpenStudy (mhchen):

Actually @518nad do you want to check my work....wow you JUST typed that

OpenStudy (mhchen):

Waiting for chaos to happen.

OpenStudy (yumi):

idk how to use that

OpenStudy (mhchen):

You can't view it?

OpenStudy (518nad):

do u have lightshot/

OpenStudy (518nad):

or take a screenshot and attach file

OpenStudy (yumi):

i mean, i dont knowhow to use that google drive thing

OpenStudy (mhchen):

I'll attach it.

OpenStudy (518nad):

thankyou -_-

OpenStudy (mhchen):

OpenStudy (mhchen):

I just realized...why did I waste my time writing the flowchart from my knowledge when I coulda searched 'bubble sort flowchart' online.

OpenStudy (518nad):

ah no this chart is a bit too vague

OpenStudy (518nad):

it should be a bit more technical

OpenStudy (mhchen):

So you want the actual lines of code in?

OpenStudy (518nad):

no u can actually follow her logic exactly in the flow chart

OpenStudy (mhchen):

:3 yep. That's for Yumi to do.

OpenStudy (518nad):

she has to implement both for loops properly

OpenStudy (518nad):

oh okay thats fine then I thought u were doing the whole thing for her

OpenStudy (yumi):

its my first semester, i just needed help

OpenStudy (yumi):

thanks tho

OpenStudy (yumi):

ive done algorithms for past assignments, just this one had me very confused

OpenStudy (518nad):

okay ill show u the bubblesort part for the 2 for loops

OpenStudy (518nad):

for (int k = a.length - 1; k > 0; k--) { for (int p = 0; p < k; p++) { if (a[p] > a[p + 1]) { temp = a[p]; a[p] = a[p + 1]; a[p + 1] = temp;

OpenStudy (yumi):

?

OpenStudy (yumi):

thanks anyway

OpenStudy (518nad):

http://prntscr.com/d9s3hn

OpenStudy (518nad):

umm a little patience please?

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!