daily pastebin goal
55%
SHARE
TWEET

Untitled

a guest Jan 21st, 2018 42 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Andrew Lohr
  2. //Assignment 9
  3. //March 22
  4.  
  5. import javax.swing.JOptionPane;
  6. public class Semester2Assignment9
  7. {
  8.   public static void main (String args[])
  9.   {
  10.  
  11.    LinkedList myList;
  12.    myList = new LinkedList();
  13.    String character;
  14.    Character response,data;
  15.    
  16.    
  17.    character = JOptionPane.showInputDialog("Enter a character");
  18.    response = character.charAt(0);
  19.    data = new Character (response);
  20.    
  21.    
  22.    while (response != '.' )
  23.    {
  24.      
  25.      myList.add(1,response);
  26.      myList.add(myList.size()+1,response);
  27.      character = JOptionPane.showInputDialog("Enter another character");
  28.      response = character.charAt(0);
  29.      data = new Character (response);
  30.    }
  31.    
  32.    System.out.println("The size of the list is: " + myList.size());
  33.    System.out.println("The contents of the list are: ");
  34.    
  35.     for(int i = 1; i <=myList.size(); i++)
  36.     {
  37.     System.out.print(myList.get(i)+ " " );
  38.     }
  39.  
  40.   }
  41. }
  42. Welcome to DrJava.  Working directory is C:\Users\Andrew
  43. > run Semester2Assignment9
  44. The size of the list is: 16
  45. The contents of the list are:
  46. H g F e D c B a a B c D e F g H >
  47.  
  48. Welcome to DrJava.  Working directory is C:\Users\Andrew
  49. > run Semester2Assignment9
  50. The size of the list is: 20
  51. The contents of the list are:
  52. K @ * 8 % b [ & W s s W & [ b % 8 * @ K >
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top