Question
import java.util.Scanner; public class Test { public static void main(String[] args) { boolean done=false; int number = 0; Assignment head = null; while(!done) { @SuppressWarnings(resource)
import java.util.Scanner;
public class Test {
public static void main(String[] args) { boolean done=false; int number = 0; Assignment head = null; while(!done) { @SuppressWarnings("resource") Scanner myObj = new Scanner(System.in); menu(); System.out.println("Please enter number.Press -1 to stop entering"); number = myObj.nextInt(); switch(number) { case 1: System.out.println("adding a new assignment"); head=insertEnd(head); break; case 2: System.out.println("remove an assignment"); Scanner myObj1 = new Scanner(System.in); System.out.println("Please enter coursename"); String search = myObj1.next(); searchAssignment(search,head); break; case 3: System.out.println("print out all assignment"); printList(head); break; case -1: done=true; break; default: System.out.println("error"); break; } } } public static void menu() { System.out.println("Please choose any one of these options"); System.out.println("1-enter new assignment"); System.out.println("2-remove assignment"); System.out.println("3-print out all assignment"); } public static void printList(Assignment head) { Assignment curr=head; System.out.println("Print out the linked list content"); while(curr!=null) { System.out.println("Yahoo"); System.out.println(curr.course_id); System.out.println(curr.course_name); System.out.println(curr.assignment_name); System.out.println(curr.assignment_due); curr=curr.next; } } public static Assignment insertEnd(Assignment head){ Assignment temp=new Assignment(); if(head==null)return temp; Assignment curr=head; while(curr.next!=null){ curr=curr.next; } curr.next=temp; return head; } public static void searchAssignment(String search,Assignment head) { Assignment curr=head; System.out.println("Print out the linked list content"); System.out.println(search); while(curr!=null) { // System.out.println(curr.course_id); if(curr.course_name=="algo") { System.out.println("hello"); break; } // System.out.println(curr.assignment_name); // System.out.println(curr.assignment_due); curr=curr.next; } } }
//this code has no errors but search there is problems it is not processing the IF statement properly
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started