Answer to Question #319986 in Java | JSP | JSF for Hussain

Question #319986

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int[] arr = new int[7]; boolean isSorted = true; int buf; for (int i = 0; i < arr.length; i++) { System.out.print("Month " + (i + 1) + ": "); arr[i] = in.nextInt(); } for (int i = 0; i < arr.length; i++){ for (int j = 0; j < arr.length - 1; j++) { if (arr[i] < arr[j]) { buf = arr[i]; arr[i] = arr[j]; arr[j] = buf; } } } for (int i : arr) { System.out.print(i + " "); } } }


This is the code i want pseudocode and flowchart of this code.

1
Expert's answer
2022-03-29T16:48:55-0400
/*

In the main function
   Declare an array of 7 elements

   Repeat steps 0 to 7{
       Get number from user
   }

   Repeat steps 0 to 7{
       Repeat steps 0 to 7{
           Compare all numbers with each other

               If the first number is less than the second,
               we swap them so that the smaller number goes forward and the larger one goes back.
               If the first number is greater than the second,
               skip and compare the first with the third, and so on.
               When we compare the first number with all, we move on to the second and so on.
       }
   }

   Repeat steps 0 to 7{
       Output all sorted numbers from the array
   }

 */

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS