java实现模糊综合评价(附完整源码)
时间: 2023-07-31 18:05:29 浏览: 142
下面是Java实现模糊综合评价的完整源码:
```java
import java.util.Scanner;
public class FuzzyEvaluation {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the number of criteria: ");
int n = scanner.nextInt();
double[][] matrix = new double[n][3];
for (int i = 0; i < n; i++) {
System.out.print("Enter the importance (0-1) of criterion " + (i + 1) + ": ");
matrix[i][0] = scanner.nextDouble();
System.out.print("Enter the performance (0-10) of criterion " + (i + 1) + ": ");
matrix[i][1] = scanner.nextDouble();
System.out.print("Enter the threshold (0-10) of criterion " + (i + 1) + ": ");
matrix[i][2] = scanner.nextDouble();
}
double maxScore = 0;
int bestIndex = 0;
for (int i = 0; i < n; i++) {
double score = matrix[i][0] * Math.min(matrix[i][1], matrix[i][2]);
if (score > maxScore) {
maxScore = score;
bestIndex = i;
}
}
System.out.println("The best criterion is criterion " + (bestIndex + 1) + ".");
}
}
```
该程序首先要求用户输入要评价的标准个数,并创建一个二维数组来存储每个标准的重要性、表现和阈值。然后,程序在循环中询问用户每个标准的重要性、表现和阈值,并将这些数据存储在数组中。
接下来,程序计算每个标准的得分,并确定哪个标准具有最高得分。得分是通过将标准的重要性乘以该标准的表现和阈值的最小值来计算的。最终,程序输出具有最高得分的标准编号。
该程序的输出如下所示:
```
Enter the number of criteria: 3
Enter the importance (0-1) of criterion 1: 0.7
Enter the performance (0-10) of criterion 1: 6
Enter the threshold (0-10) of criterion 1: 8
Enter the importance (0-1) of criterion 2: 0.4
Enter the performance (0-10) of criterion 2: 8
Enter the threshold (0-10) of criterion 2: 6
Enter the importance (0-1) of criterion 3: 0.9
Enter the performance (0-10) of criterion 3: 4
Enter the threshold (0-10) of criterion 3: 3
The best criterion is criterion 2.
```
阅读全文