What's new

Closed JAVA QUEUE

Status
Not open for further replies.

Penpenqt69

Addict
Joined
Jul 31, 2018
Posts
36
Reaction
3
Points
79
Age
24
Code:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaqeue;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Queue;
import java.util.LinkedList;
/**
 *
 * @author Jonathan
 */

public class JavaQeue {
public static int Select;
public static int JustAnArray[]= new int [100];
public static int ctr=0;


    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Queue<Integer> q = new LinkedList<>();
        // TODO code application logic here
     //Menu
     Scanner put = new Scanner (System.in);
     do{
        
         System.out.print("<<<QEUE MENU>>>\n[1]ADD\n[2]Remove\n[3]Display\n[4]Close The program\nSELECT: ");
     Select = put.nextInt();
     int Selection = Select;
    
     }while(Select<=3);
    }
    static void Selection(int s){
        switch(s)
        {
            case 1: ADD();break;
            case 2: REMOVE();break;
            case 3: DISPLAY();break;
            case 4: EXIT();break;
        }   System.exit(0);
        }
    
static void ADD(){
for (int i=0;i<JustAnArray.length;i++)
    q.add(i);
System.out.print("Elements"+Arrays.toString(JustAnArray));
}

static void REMOVE(){
    int RemoveMe = q.remove();
    System.out.print("Removed element: "+RemoveMe);
}
static void DISPLAY(){
    int pik =q.peek();
    System.out.print("Elements"+pik);
}
static void EXIT(){
    System.exit(0);
}
}
OUTPUT:
<<<QEUE MENU>>>
[1]ADD
[2]Remove
[3]Display
[4]Close The program
SELECT: 1
nagiging infinite loop po sya pag nag eenter po ako
how to fix po ito?


THANK YOUUU
 
Code:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaqeue;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Queue;
import java.util.LinkedList;
/**
*
* @author Jonathan
*/

public class JavaQeue {
public static int Select;
public static int JustAnArray[]= new int [100];
public static int ctr=0;


    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Queue<Integer> q = new LinkedList<>();
        // TODO code application logic here
     //Menu
     Scanner put = new Scanner (System.in);
     do{
       
         System.out.print("<<<QEUE MENU>>>\n[1]ADD\n[2]Remove\n[3]Display\n[4]Close The program\nSELECT: ");
     Select = put.nextInt();
     int Selection = Select;
   
     }while(Select<=3);
    }
    static void Selection(int s){
        switch(s)
        {
            case 1: ADD();break;
            case 2: REMOVE();break;
            case 3: DISPLAY();break;
            case 4: EXIT();break;
        }   System.exit(0);
        }
   
static void ADD(){
for (int i=0;i<JustAnArray.length;i++)
    q.add(i);
System.out.print("Elements"+Arrays.toString(JustAnArray));
}

static void REMOVE(){
    int RemoveMe = q.remove();
    System.out.print("Removed element: "+RemoveMe);
}
static void DISPLAY(){
    int pik =q.peek();
    System.out.print("Elements"+pik);
}
static void EXIT(){
    System.exit(0);
}
}
OUTPUT:
<<<QEUE MENU>>>
[1]ADD
[2]Remove
[3]Display
[4]Close The program
SELECT: 1
nagiging infinite loop po sya pag nag eenter po ako
how to fix po ito?


THANK YOUUU
ok na? nag run na as expected ang program?
 
Status
Not open for further replies.

Similar threads

Back
Top