Untitled

 avatar
Itiswhatitis
java
2 years ago
1.3 kB
3
Indexable
Never
public void print_gantt_chart()
        {
        int i, j;
        
        // print top bar


        System.out.print(" ");
        for(i=0; i<n; i++)
        {
        for(j=0; j<p[i].burst_time; j++)
            System.out.print("--");
        System.out.print(" ");
        }
        System.out.println();

        // printing process id in the middle
        for(i=0; i<n; i++) {
        for(j=0; j<p[i].burst_time - 1; j++)
            System.out.print(" ");
        
            //  !! fix this according to what will be passed printf("P%d", p[i].pid);
        for(j=0; j<p[i].burst_time - 1; j++) System.out.print(" ");
        System.out.print("|");
        }
        System.out.print("\n ");
        // printing bottom bar
        for(i=0; i<n; i++) {
        for(j=0; j<p[i].burst_time; j++) System.out.print("--");
        System.out.print(" ");
        }
        System.out.print("\n");

        // printing the time line
        System.out.print("0");
        for(i=0; i<n; i++) {
        for(j=0; j<p[i].burst_time; j++) System.out.print("  ");;
        if(p[i].turnaround_time > 9) printf("\b"); // backspace : remove 1 space
        //  !! fix this according to what will be passed printf("%d", p[i].turnaround_time);

        }
        System.out.print("\n");

        }