Advertisement
oona

mla format

Mar 13th, 2014
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.01 KB | None | 0 0
  1. public class mlaFormat {
  2.  
  3.     public static void main(String[] args) {
  4.         // TODO Auto-generated method stub
  5.        
  6.         String firstName[] = {"Mark", "Sue", "Jaqcueline", "Jerzy", "Temple", "Truman"}; //authors' first name
  7.         String lastName[] = {"Haddon", "Monk Kidd", "Wilson", "Kosinski", "Grandin", "Capote"}; //authors' last name
  8.         String bookName[] = {"The Curious Incident of the Dog in the Night-Time", "The Secret Life of Bees", "Bad Girls", "Being There", "Thinking in Pictures",  "Breakfast at Tiffany's"}; //book titles
  9.         String publisherName[] = {"Vintage", "Headline Book Publishing", "Corgi Yearling", "Black Swan", "Bloomsbury", "Vintage International"}; //publishers
  10.         String yearPublished[] = {"2003", "2002", "1996", "1970", "1995", "1957"}; //year of publication
  11.        
  12.         mlaFormat(firstName, lastName, bookName, publisherName, yearPublished);
  13.  
  14.     } //main ends here
  15.    
  16.     static void mlaFormat(String[] firstName, String[] lastName, String[] bookName, String[] publisherName, String[] yearPublished)
  17.     {
  18.         for(int i=0; i<lastName.length; i++)
  19.         {
  20.             for(int j=1; j<(lastName.length-i); j++)
  21.             {
  22.                 if(lastName[j-1].compareTo(lastName[j])>0)
  23.                 {
  24.                     String temp1 = firstName[j-1];
  25.                     firstName[j-1] = firstName[j];
  26.                     firstName[j] = temp1;
  27.                    
  28.                     String temp2 = lastName[j-1];
  29.                     lastName[j-1] = lastName[j];
  30.                     lastName[j] = temp2;
  31.                    
  32.                     String temp3 = bookName[j-1];
  33.                     bookName[j-1] = bookName[j];
  34.                     bookName[j] = temp3;
  35.                    
  36.                     String temp4 = publisherName[j-1];
  37.                     publisherName[j-1] = publisherName[j];
  38.                     publisherName[j] = temp4;
  39.                    
  40.                     String temp5 = yearPublished[j-1];
  41.                     yearPublished[j-1] = yearPublished[j];
  42.                     yearPublished[j] = temp5;
  43.                        
  44.                 } // if statement ends here
  45.             } // inner for loop ends here
  46.            
  47.         } // outer for loop ends here
  48.        
  49.         for(int i = 0; i<firstName.length; i++)
  50.             System.out.println(lastName[i] + ", " + firstName[i] + ". '" + bookName[i] + "', " + publisherName[i] + ", " + yearPublished[i]);
  51.        
  52.     }
  53.  
  54. } //program ends
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement