Assignment10 - Assignment 10 Name Michael Lewandowski StudentID:1207124915 Lecture TTH 10:30-11:45 Description This program does various things to a

Assignment10 - Assignment 10 Name Michael Lewandowski...

This preview shows page 1 - 2 out of 2 pages.

// Assignment 10 // Name: Michael Lewandowski // StudentID:1207124915 // Lecture: TTH 10:30-11:45 // Description: This program does various things to a linked list. import java.io.*; public class Assignment10 { public static void main(String[] args) { char input1; String inputInfo = new String(); int operation2; String line = new String(); //create a linked list to be used in this method. LinkedList list1 = new LinkedList(); try { // print out the menu printMenu(); // create a BufferedReader object to read input from a keyboard InputStreamReader isr = new InputStreamReader (System.in); BufferedReader stdin = new BufferedReader (isr); do { System.out.print("What action would you like to perform?\n"); line = stdin.readLine().trim(); //read a line input1 = line.charAt(0); input1 = Character.toUpperCase(input1); if (line.length() == 1) //check if a user entered only one character { switch (input1) { case 'A': //Add String Once System.out.print("Please enter a string to add:\n"); String str1 = stdin.readLine().trim(); list1.addElement(str1); break; case 'B': //Add String Multiple Times System.out.print("Please enter a string to add:\n"); String str2 = stdin.readLine().trim();

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture