Программа о "сделать это первым приоритетом". Мне нужна помощь, как получить номер задания с наибольшим количеством WSJF, используя массивы. Мой код отображает наибольшее количество WSFJ, но я хочу отобразить количество заданий с наибольшим номером WSFJ.
publi c class main {
public static void main(String[] args) {
int jobs = 0;
int BD = 0;
int TI = 0;
int RR = 0;
int size = 0;
double CoD = 0.0;
double WSJF = 0.0;
Calculate cal = new Calculate(BD, TI, RR, size, CoD, WSJF);
Scanner sc = new Scanner(System.in);
System.out.println("How many jobs do you want to calculate? ");
jobs = sc.nextInt();
int jobNum[] = new int[jobs];
for(int i = 0; i < jobs; i++) {
System.out.println("Please enter the business data: ");
cal.setBusinessData(sc.nextInt());
System.out.println("Please enter the timing impact: ");
cal.setTimingImpact(sc.nextInt());
System.out.println("Please enter the risk reduction: ");
cal.setRiskReduction(sc.nextInt());
System.out.println("Please enter the size: ");
cal.setSize(sc.nextInt());
System.out.println("Job number: #" + (i+1));
System.out.println("Business data: " + cal.getBusinessData());
System.out.println("Timing impact: " + cal.getTimingImpact());
System.out.println("Risk reduction: " + cal.getRiskReduction());
System.out.println("Size: " + cal.getSize());
System.out.println("Cost of delay: " + cal.getCostOfDelay());
System.out.println("WSJF: " + cal.getWSJF());
System.out.println();
}
// Displays the highest number of WSJF but I want to display the job # that has the highest number of WSJF
System.out.println("The job that you should focus first is the number " + cal.getMax(jobNum));
}
}
publi c класс StoreData {
int businessData;
int timingImpact;
int riskReduction;
int size;
public StoreData(int businessData, int timingImpact, int riskReduction, int size) {
this.businessData = businessData;
this.timingImpact = timingImpact;
this.riskReduction = riskReduction;
this.size = size;
}
/**
* @return the businessData
*/
public int getBusinessData() {
return businessData;
}
/**
* @return the timingImpact
*/
public int getTimingImpact() {
return timingImpact;
}
/**
* @return the riskReduction
*/
public int getRiskReduction() {
return riskReduction;
}
/**
* @return the size
*/
public int getSize() {
return size;
}
/**
* @param businessData the businessData to set
*/
public void setBusinessData(int businessData) {
this.businessData = businessData;
}
/**
* @param timingImpact the timingImpact to set
*/
public void setTimingImpact(int timingImpact) {
this.timingImpact = timingImpact;
}
/**
* @param riskReduction the riskReduction to set
*/
public void setRiskReduction(int riskReduction) {
this.riskReduction = riskReduction;
}
/**
* @param size the size to set
*/
public void setSize(int size) {
this.size = size;
}
}
publi c класс Calculate extends StoreData {
double costOfDelay;
double WSJF;
public Calculate (int businessData, int timingImpact, int riskReduction, int size, double costOfDelay, double WSJF) {
super(businessData, timingImpact, riskReduction, size);
this.costOfDelay = costOfDelay;
this.WSJF = WSJF;
}
/**
* @return the costOfDelay
*/
public double getCostOfDelay() {
return businessData + timingImpact + riskReduction;
}
/**
* @return the wSJF
*/
public double getWSJF() {
return getCostOfDelay()/size;
}
/**
* @param costOfDelay the costOfDelay to set
*/
public void setCostOfDelay(double costOfDelay) {
this.costOfDelay = costOfDelay;
}
/**
* @param wSJF the wSJF to set
*/
public void setWSJF(double wSJF) {
this.WSJF = wSJF;
}
public int getMax(int[] jobNum) {
int max = (int) getWSJF();
for(int i = 0; i < jobNum.length; i++) {
if(getWSJF() > max) {
max = (int) getWSJF();
}
}
return max;
}
}