lease modify my program so that the output will print like what is in the picture. Thank you in advance.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Please modify my program so that the output will print like what is in the picture. Thank you in advance.




import java.util.*;

public class sales 
{
        public static void main(String[] args) 
        {
            Scanner kbd = new Scanner(System.in);
            String[] names;
            String[] address;
            String[] age;
            // String[] age;
            int n = 0;
            boolean successfulRead=false;
            do 
            {
                try
                {
                    System.out.println("How many names will be sorted: ");
                    n = Integer.parseInt(kbd.nextLine());
                    if (n >=0 )
                    {
                        successfulRead = true;
                    }
                    else
                    {
                        System.out.println("The amount cannot be a negative amount");
                        successfulRead = false;
                    }
                }
                catch (NumberFormatException e)
                {
                    successfulRead = false;
                    System.out.println("You have enetered an invalid amount");
                }
            } while (!successfulRead);
            names = new String[n];
            address = new String[n];
            age = new String[n];
            // Populate array names
            for (int z = 0; z < names.length; z++) 
            {
                System.out.print("Enter name of salesmen " + (z + 1) + ": ");
                names[z] = kbd.nextLine();
            }
            for (int z = 0; z < address.length; z++) 
            {
                System.out.print("Enter address of salesmen " + (z + 1) + ": ");
                address[z]= kbd.nextLine();
            }
            for (int z = 0; z < age.length; z++) 
            {
                System.out.print("Enter age of salesmen " + (z + 1) + ": ");
                age[z]= kbd.nextLine();
            }
            // Sort the names array
            balloonSortArray2(names);
            //Show elements of names array
            System.out.print("Sorted name of salesmen ");
            showElements(names);
            // Sort the address array
            balloonSortArray2(address);
            //Show elements of address array
            System.out.print("Sorted address of salesmen ");
            showElements(address);
            // Sort the age array
            balloonSortArray2(age);
            //Show elements of age array
            System.out.print("Sorted age of salesmen ");
            showElements(age);
            
        }

    public static void balloonSortArray2(String[] given)
    {
        for (int x = 0; x < given.length - 1; x++) 
        {
            for (int y = x + 1; y < given.length; y++) 
            {
                if (given[x].compareTo(given[y]) > 0) 
                {
                    String temp = given[x];
                    given[x] = given[y];
                    given[y] = temp;
                } // end of if
            } // end of second for
        } // end of first for
    } // end of method

    public static void showElements(String[] array) 
    {
        System.out.print("Sorted Name \t\t Sorted Address \t\t Sorted age");
        for (int x = 0; x < array.length; x++)
            System.out.println(array[x]);
    }
}

 

Sorted name of salesmen
Sorted address of salesmen
Sorted age of salesmen
Jon
Arizona Usa
24
Jonson
California usa
25
Mike
San Francisco Usa
26
Transcribed Image Text:Sorted name of salesmen Sorted address of salesmen Sorted age of salesmen Jon Arizona Usa 24 Jonson California usa 25 Mike San Francisco Usa 26
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education