import javax.swing.JOptionPane;
/*
* 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.
*/
/**
*
* @author Hellblazer
*/
public class FifoAl {
public static void main(String args[]){
int t=0;
String cadena;
cadena=JOptionPane.showInputDialog("Numero de procesos: ");
t=Integer.parseInt(cadena);
int Ar[];
Ar = new int[t];
PideDatos(Ar);
ImprimeArreglo(Ar);
CalculaTPR(Ar);
}
public static void ImprimeArreglo(int Ar[]){
System.out.print("P\t"+"TLL\n");
for(int i=0; i<Ar.length; i++)
System.out.print("P"+(i+1)+"\t"+Ar[i]+"\n");
}
public static void PideDatos(int Ar[]){
for(int i=0; i<Ar.length; i++){
String cadena=JOptionPane.showInputDialog("Tiempo de espera de P"+(i+1)+":");
Ar[i]=Integer.parseInt(cadena);
}
}
public static void CalculaTPR(int Ar[]){
float suma=0;
for(int i=0;i< Ar.length; i++)
suma+=Ar[i]*(Ar.length-i);
float tpr=suma/Ar.length;
System.out.print("Tpr= "+tpr);
System.out.println();
}
}