Name_Array - Temp = L_Name[i+1]; L_Name[i+1] = L_Name[i];...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.util.*; import java.lang.*; import java.io.*; import java.text.*; import java.math.*; import java.text.DecimalFormat; // Jeremy Debruce // Bubble Sort / public class Name_Array { static Scanner console = new Scanner(System.in); static int j,i,min; public static void main(String[] args) throws FileNotFoundException { System.out.println("*************************************************************** ****"); System.out.println("*The purpose of this program is to print out the last name with *"); System.out.println("* the right first name using the arrays. *"); System.out.println("****************************************************** *************"); System.out.println(); String[] F_Name = {"Jeremy","Johnny","Donterrious","Willie","Anthony","Courtney","Jeremy"}; String[] L_Name = {"Johnson","Devine","Daniels","Jackson","Williams","Beach","Debruce"}; String Temp; for(i=6;i>=0;i--) for(j=i;j<=i;j++) if(F_Name[i].equals(L_Name[i])) { Temp = F_Name[i+1]; F_Name[i+1] = F_Name[i]; F_Name[i] = Temp;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Temp = L_Name[i+1]; L_Name[i+1] = L_Name[i]; L_Name[i] = Temp; } System.out.println(&quot;First Name Last Name. &quot;); S System.out.println(&quot;_____________________________&quot;); System.out.println(); S for(i=0;i&lt;=6;i++) { System.out.print(i+1+ &quot;. &quot;); System.out.printf(&quot;%-15s %-600s%n&quot;,F_Name[i],L_Name[i]); System.out.println(); } System.out.println(); System.out.println(); System.out.println(&quot;_____________________________&quot;); System.out.println(&quot;Last Name First Name. &quot;); S System.out.println(&quot;_____________________________&quot;); System.out.println(); S for (i=0;i&lt;L_Name.length-1;i++) { min = i; for(j=i+1;j&lt;L_Name.length;j++) if(L_Name[j].compareTo(L_Name[min])&lt;0) min =j; Temp = L_Name[i]; L_Name[i] = L_Name[min]; L_Name[min] = Temp; Temp = F_Name[i]; F_Name[i] = F_Name[min]; F_Name[min] = Temp; System.out.print(i+1+ &quot;. &quot;); System.out.printf(&quot;%-15s %-600s%n&quot;,L_Name[i],F_Name[i]); System.out.println(); } System.out.println(&quot;Have a nice day&quot;); } }...
View Full Document

Page1 / 2

Name_Array - Temp = L_Name[i+1]; L_Name[i+1] = L_Name[i];...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online