๐Ÿ”’ Closed Pa help po Data Structure

Status
Not open for further replies.

EpicPrivacy

Eternal Poster
Code:
do{
        System.out.println("Note: You can enter Small and Big Letter");
        System.out.println("Choices: ");
        System.out.println("\t[I] โ€“ Insert");
        System.out.println("\t[D] โ€“ Delete");
        System.out.println("\t[S] โ€“ Search");
        System.out.println("\t[P] โ€“ Print");
        System.out.println("\t[C] - Close");
       
        System.out.print("Enter you choise: ");
        choise = scan.next().charAt(0);
       
        // Enter
            if(choise == 'I' || choise == 'i'){
                System.out.print("Enter an integer: ");
                enter = scan1.nextInt();
                List.Add(enter);
                System.out.print("\n");
            }
        // Delete
            if(choise == 'D' || choise == 'd'){
                List.Delete();
           for (Node q = head; q !=null; q = q.next)
        System.out.println("The integers are: " + q.data);
                System.out.print("\n");
            }
        // Search
            if(choise == 'S' || choise == 's'){
             
        System.out.print("Enter the number to be searched: ");
                search = scan1.nextInt();
                for (Node q = head; q !=null; q = q.next)
                if(search != q.data){
                System.out.print(search + " is not in the list");
                System.out.print("\n\n");
                }else{
                System.out.print(search + " is in the list");
                System.out.print("\n\n");
                }
                System.out.print("\n\n");
               
            }
        // Printing
            if(choise == 'P' || choise == 'p'){
                for (Node q = head; q !=null; q = q.next)
                System.out.println("The integers are: " + q.data);
                System.out.print("\n");
            }
        // Close
        }while(choise != 'C' && choise != 'c');

         System.out.print("Closing the program. Thank you!\n");
         System.exit(0);


pano po kaya ma fix to:

Note: You can enter Small and Big Letter
Choices:
โ€“ Insert
[D] โ€“ Delete
โ€“ Search
[P] โ€“ Print
[C] - Close
Enter you choise: i
Enter an integer: 10

Note: You can enter Small and Big Letter
Choices:
โ€“ Insert
[D] โ€“ Delete
โ€“ Search
[P] โ€“ Print
[C] - Close
Enter you choise: i
Enter an integer: 100

Note: You can enter Small and Big Letter
Choices:
โ€“ Insert
[D] โ€“ Delete
โ€“ Search
[P] โ€“ Print
[C] - Close
Enter you choise: i
Enter an integer: 200

Note: You can enter Small and Big Letter
Choices:
โ€“ Insert
[D] โ€“ Delete
โ€“ Search
[P] โ€“ Print
[C] - Close
Enter you choise: s
Enter the number to be searched: 90
90 is not in the list

90 is not in the list

90 is not in the list



Note: You can enter Small and Big Letter
Choices:
โ€“ Insert
[D] โ€“ Delete
โ€“ Search
[P] โ€“ Print
[C] - Close
Enter you choise: p
The integers are: 200
The integers are: 100
The integers are: 10



nag dodoble doble po kasi yung pag print nya ng 90 is not in the list
at dun sa the integers are pano po kaya pag sunod sunudin yung output nya sample The integers are: 10 100 200
 
Yung sa bandang search mo po ay hindi naka enclosed sa loop (curly braces) yung mga conditional statements mo.
Para hindi mag multiple print try mo po,
Java:
if(search == q.data)
//Then print search is in the list.
 
Status
Not open for further replies.

About this Thread

  • 1
    Replies
  • 367
    Views
  • 2
    Participants
Last reply from:
Arcturus

Online now

Members online
1,044
Guests online
680
Total visitors
1,724

Forum statistics

Threads
2,276,962
Posts
28,973,362
Members
1,229,667
Latest member
Kismut26
Back
Top