代码拉取完成,页面将自动刷新
warning: in the working copy of 'array_src/practices_ary/ForOrderProcessingSystem.java', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'array_src/practices_ary/ForSalesDataAnalysis.java', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'array_src/practices_ary/ForStudentGradeProcessor.java', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'array_src/practices_ary/ForUserAgeAnalysis.java', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'oop/project/banks/README', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'while_and_if/practices_while/ControlGameScoreSystem.java', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'while_and_if/practices_while/ControlInventoryCheck.java', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'while_and_if/practices_while/ControlPaginationSystem.java', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'while_and_if/practices_while/ControlUserRegistrationSystem.java', LF will be replaced by CRLF the next time Git touches it
[1mdiff --git a/array_src/practices_ary/ForOrderProcessingSystem.java b/array_src/practices_ary/ForOrderProcessingSystem.java[m
[1mindex 27c0f02..d250397 100644[m
[1m--- a/array_src/practices_ary/ForOrderProcessingSystem.java[m
[1m+++ b/array_src/practices_ary/ForOrderProcessingSystem.java[m
[36m@@ -17,9 +17,19 @@[m [mpublic class ForOrderProcessingSystem {[m
double totalAmount = calculateTotal(orders);[m
System.out.println("订单的总金额: $" + totalAmount);[m
[m
[31m- // 查找订单金额大于某个阈值的订单,并返回这些订单的索引[m
[32m+[m[32m // 查找订单金额最接近 /某个阈值的订单,并返回这些订单的索引[m
int idx = findOrdersAboveThreshold(orders, threshold);[m
System.out.println("最接近阈值 $" + threshold + "的索引 " + idx);[m
[32m+[m[32m }[m
[32m+[m[32m public static void calculateTotal(double[] orders){[m
[32m+[m[32m double total = 0.0;[m
[32m+[m[32m for (double order : orders){[m
[32m+[m[32m total += order;[m
[32m+[m[32m }[m
[32m+[m[32m return total;[m
[32m+[m[32m }[m
[32m+[m[32m public static int findOrdersAboveThreshold(double[] orders,double[] threshold){[m
[32m+[m
}[m
// 补充calculateTotal、findOrdersAboveThreshold方法定义以及实现[m
}[m
[1mdiff --git a/array_src/practices_ary/ForSalesDataAnalysis.java b/array_src/practices_ary/ForSalesDataAnalysis.java[m
[1mindex 2dbb0bf..1a49f02 100644[m
[1m--- a/array_src/practices_ary/ForSalesDataAnalysis.java[m
[1m+++ b/array_src/practices_ary/ForSalesDataAnalysis.java[m
[36m@@ -1,15 +1,15 @@[m
package practices_ary;[m
[m
[31m-/**[m
[31m- * 2. 销售数据分析[m
[31m- *[m
[31m- * 需求: 实现一个销售数据分析系统。给定一个数组,其中每个元素表示一个月的销售额。计算以下内容:[m
[31m- *[m
[31m- * • 总销售额[m
[31m- * • 平均销售额[m
[31m- * • 销售额最高的月份[m
[31m- * • 销售额最低的月份[m
[31m- * */[m
[32m+[m[32m///**[m
[32m+[m[32m// * 2. 销售数据分析[m
[32m+[m[32m// *[m
[32m+[m[32m// * 需求: 实现一个销售数据分析系统。给定一个数组,其中每个元素表示一个月的销售额。计算以下内容:[m
[32m+[m[32m// *[m
[32m+[m[32m// * • 总销售额[m
[32m+[m[32m// * • 平均销售额[m
[32m+[m[32m// * • 销售额最高的月份[m
[32m+[m[32m// * • 销售额最低的月份[m
[32m+[m[32m// * */[m
public class ForSalesDataAnalysis {[m
public static void main(String[] args) {[m
double[] sales = {1200.50, 1500.75, 1300.00, 1100.25, 1700.80, 1600.90, 1400.60, 1550.50, 1650.00, 1800.70, 1900.80, 2000.00};[m
[36m@@ -27,5 +27,39 @@[m [mpublic class ForSalesDataAnalysis {[m
System.out.println("Highest Sales Month: " + months[maxIndex] + " ($" + sales[maxIndex] + ")");[m
System.out.println("Lowest Sales Month: " + months[minIndex] + " ($" + sales[minIndex] + ")");[m
}[m
[32m+[m
[32m+[m[32m public static double calculateTotal(double[] sales){[m
[32m+[m[32m double total = 0.0;[m
[32m+[m[32m for (double sale : sales){[m
[32m+[m[32m total += sale;[m
[32m+[m[32m }[m
[32m+[m[32m return total;[m
[32m+[m[32m }[m
[32m+[m
[32m+[m[32m public static double calculateAverage(double[] sales){[m
[32m+[m[32m double total = calculateTotal(sales);[m
[32m+[m[32m total = total / sales.length;[m
[32m+[m[32m return total;[m
[32m+[m[32m }[m
[32m+[m
[32m+[m[32m public static int findMaxIndex(double[] sales){[m
[32m+[m[32m int maxIndex = 0;[m
[32m+[m[32m for (int i = 1; i < sales.length;i++){[m
[32m+[m[32m if (sales[i] > sales[maxIndex]){[m
[32m+[m[32m sales[maxIndex] = sales[i];[m
[32m+[m[32m }[m
[32m+[m[32m }[m
[32m+[m[32m return maxIndex;[m
[32m+[m[32m }[m
[32m+[m
[32m+[m[32m public static int findMinIndex(double[] sales){[m
[32m+[m[32m int minIndex = 0;[m
[32m+[m[32m for (int i = 1; i < sales.length;i++){[m
[32m+[m[32m if (sales[i] < sales[minIndex]){[m
[32m+[m[32m sales[minIndex] = sales[i];[m
[32m+[m[32m }[m
[32m+[m[32m }[m
[32m+[m[32m return minIndex;[m
[32m+[m[32m }[m
// 补充以上calculateTotal、calculateAverage、findMaxIndex、findMinIndex方法定义以及实现[m
}[m
[1mdiff --git a/array_src/practices_ary/ForStudentGradeProcessor.java b/array_src/practices_ary/ForStudentGradeProcessor.java[m
[1mindex c5780de..8dd642b 100644[m
[1m--- a/array_src/practices_ary/ForStudentGradeProcessor.java[m
[1m+++ b/array_src/practices_ary/ForStudentGradeProcessor.java[m
[36m@@ -26,5 +26,39 @@[m [mpublic class ForStudentGradeProcessor {[m
System.out.println("Highest Grade: " + grades[maxIndex] + " (Student Index: " + maxIndex + ")");[m
System.out.println("Lowest Grade: " + grades[minIndex] + " (Student Index: " + minIndex + ")");[m
}[m
[32m+[m
[32m+[m[32m public static int calculateTotal(int[] grades){[m
[32m+[m[32m int total = 0;[m
[32m+[m[32m for (int grade : grades){[m
[32m+[m[32m total += grade;[m
[32m+[m[32m }[m
[32m+[m[32m return total;[m
[32m+[m[32m }[m
[32m+[m
[32m+[m[32m public static int calculateAverage(int[] grades){[m
[32m+[m[32m int total = calculateAverage(grades);[m
[32m+[m[32m total = total / grades.length;[m
[32m+[m[32m return total;[m
[32m+[m[32m }[m
[32m+[m
[32m+[m[32m public static int findMaxIndex(int[] grades){[m
[32m+[m[32m int maxIndex = 0;[m
[32m+[m[32m for (int i = 1; i < grades.length;i++){[m
[32m+[m[32m if (grades[i] > grades[maxIndex]){[m
[32m+[m[32m grades[maxIndex] = grades[i];[m
[32m+[m[32m }[m
[32m+[m[32m }[m
[32m+[m[32m return maxIndex;[m
[32m+[m[32m }[m
[32m+[m
[32m+[m[32m public static int findMinIndex(int[] grades){[m
[32m+[m[32m int minIndex = 0;[m
[32m+[m[32m for (int i = 1; i < grades.length;i++){[m
[32m+[m[32m if (grades[i] < grades[minIndex]){[m
[32m+[m[32m grades[minIndex] = grades[i];[m
[32m+[m[32m }[m
[32m+[m[32m }[m
[32m+[m[32m return minIndex;[m
[32m+[m[32m }[m
// 补充calculateTotal、calculateAverage、findMaxIndex、findMinIndex的方法定义以及实现[m
}[m
[1mdiff --git a/array_src/practices_ary/ForUserAgeAnalysis.java b/array_src/practices_ary/ForUserAgeAnalysis.java[m
[1mindex 1bf7613..94da1d0 100644[m
[1m--- a/array_src/practices_ary/ForUserAgeAnalysis.java[m
[1m+++ b/array_src/practices_ary/ForUserAgeAnalysis.java[m
[36m@@ -26,5 +26,44 @@[m [mpublic class ForUserAgeAnalysis {[m
int countInRange = countInRange(ages, 20, 30);[m
System.out.println("年龄在20 ~ 30之间的总共: " + countInRange);[m
}[m
[32m+[m
[32m+[m[32m public static double calculateAverage(int[] ages){[m
[32m+[m[32m int sum = 0;[m
[32m+[m[32m for (int age : ages){[m
[32m+[m[32m sum += age;[m
[32m+[m[32m }[m
[32m+[m[32m sum = sum / ages.length;[m
[32m+[m[32m return sum;[m
[32m+[m[32m }[m
[32m+[m
[32m+[m[32m public static int findMax(int[] ages){[m
[32m+[m[32m int max = ages[0];[m
[32m+[m[32m for (int age : ages){[m
[32m+[m[32m if (age > max){[m
[32m+[m[32m max = age;[m
[32m+[m[32m }[m
[32m+[m[32m }[m
[32m+[m[32m return max;[m
[32m+[m[32m }[m
[32m+[m
[32m+[m[32m public static int findMin(int[] ages){[m
[32m+[m[32m int min = ages[0];[m
[32m+[m[32m for (int age : ages){[m
[32m+[m[32m if (age < min){[m
[32m+[m[32m min = age;[m
[32m+[m[32m }[m
[32m+[m[32m }[m
[32m+[m[32m return min;[m
[32m+[m[32m }[m
[32m+[m
[32m+[m[32m public static int countInRange(int[] ages , int a,int b){[m
[32m+[m[32m int total = 0;[m
[32m+[m[32m for (int age : ages){[m
[32m+[m[32m if (age >= a && age <= b){[m
[32m+[m[32m total++;[m
[32m+[m[32m }[m
[32m+[m[32m }[m
[32m+[m[32m return total;[m
[32m+[m[32m }[m
// 补充 calculateAverage、findMax、findMin、countInRange方法定义以及实现[m
}[m
[1mdiff --git a/oop/project/banks/README b/oop/project/banks/README[m
[1mindex 2dd3ca8..a05fed0 100644[m
[1m--- a/oop/project/banks/README[m
[1m+++ b/oop/project/banks/README[m
[36m@@ -1,6 +1,7 @@[m
2. 设计一个在线银行系统[m
[m
[31m-需求: 设计一个在线银行系统,包括账户和交易。账户类应包含账户的基本信息(如账户号码、账户余额)。交易类应记录每笔交易的详细信息(如交易金额、交易类型和交易日期)。系统应能够处理存款、取款和转账操作。[m
[32m+[m[32m需求: 设计一个在线银行系统,包括账户和交易。账户类应包含账户的基本信息(如账户号码、账户余额)。[m
[32m+[m[32m交易类应记录每笔交易的详细信息(如交易金额、交易类型和交易日期)。系统应能够处理存款、取款和转账操作。[m
[m
提示:[m
[m
[1mdiff --git a/while_and_if/practices_while/ControlGameScoreSystem.java b/while_and_if/practices_while/ControlGameScoreSystem.java[m
[1mindex 1603d2b..3fe38bd 100644[m
[1m--- a/while_and_if/practices_while/ControlGameScoreSystem.java[m
[1m+++ b/while_and_if/practices_while/ControlGameScoreSystem.java[m
[36m@@ -1,5 +1,7 @@[m
package practices_while;[m
[m
[32m+[m[32mimport java.util.Scanner;[m
[32m+[m
/**[m
*[m
* 游戏得分系统[m
[36m@@ -13,4 +15,33 @@[m [mpackage practices_while;[m
* • 使用 break 来结束循环并计算总分和平均分。[m
* */[m
public class ControlGameScoreSystem {[m
[32m+[m[32m public static void main(String[] args) {[m
[32m+[m[32m Scanner scanner = new Scanner(System.in);[m
[32m+[m[32m int totalScore = 0;[m
[32m+[m[32m int scoreCount = 0;[m
[32m+[m
[32m+[m[32m while(true){[m
[32m+[m[32m System.out.println("请输入得分");[m
[32m+[m[32m int score = scanner.nextInt();[m
[32m+[m
[32m+[m[32m if (score < 0){[m
[32m+[m[32m break;[m
[32m+[m[32m }[m
[32m+[m[32m if (score == 0){[m
[32m+[m[32m System.out.println("无效输入");[m
[32m+[m
[32m+[m[32m continue;[m
[32m+[m[32m }[m
[32m+[m
[32m+[m[32m totalScore += score;[m
[32m+[m[32m scoreCount++;[m
[32m+[m[32m }[m
[32m+[m
[32m+[m[32m if (scoreCount > 0){[m
[32m+[m[32m double a = totalScore / scoreCount;[m
[32m+[m[32m System.out.println("总分:" + totalScore);[m
[32m+[m[32m System.out.println("平均分:" + a);[m
[32m+[m[32m }[m
[32m+[m[32m scanner.close();[m
[32m+[m[32m }[m
}[m
[1mdiff --git a/while_and_if/practices_while/ControlInventoryCheck.java b/while_and_if/practices_while/ControlInventoryCheck.java[m
[1mindex 03e4d21..317415a 100644[m
[1m--- a/while_and_if/practices_while/ControlInventoryCheck.java[m
[1m+++ b/while_and_if/practices_while/ControlInventoryCheck.java[m
[36m@@ -1,5 +1,6 @@[m
package practices_while;[m
[m
[32m+[m[32mimport javax.swing.plaf.synth.SynthOptionPaneUI;[m
import java.util.Scanner;[m
[m
/**[m
[36m@@ -23,7 +24,20 @@[m [mpublic class ControlInventoryCheck {[m
public static void main(String[] args) {[m
Scanner scanner = new Scanner(System.in);[m
while (true){[m
[32m+[m[32m System.out.println("用户输入购买的数量");[m
[32m+[m[32m int control = scanner.nextInt();[m
[32m+[m[32m if (INVENTORY < 0){[m
[32m+[m[32m continue;[m
[32m+[m[32m }[m
[32m+[m[32m if (INVENTORY > 50){[m
[32m+[m[32m System.out.println("库存不足,当前库存为:" + INVENTORY);[m
[32m+[m[32m continue;[m
[32m+[m[32m }[m
[32m+[m
[32m+[m[32m System.out.println("库存足够,可以购买,购买数量为:" + control);[m
[32m+[m[32m break;[m
// 补充逻辑[m
}[m
[32m+[m[32m scanner.close();[m
}[m
}[m
[1mdiff --git a/while_and_if/practices_while/ControlPaginationSystem.java b/while_and_if/practices_while/ControlPaginationSystem.java[m
[1mindex 8489a77..26784af 100644[m
[1m--- a/while_and_if/practices_while/ControlPaginationSystem.java[m
[1m+++ b/while_and_if/practices_while/ControlPaginationSystem.java[m
[36m@@ -18,8 +18,22 @@[m [mpublic class ControlPaginationSystem {[m
[m
public static void main(String[] args) {[m
Scanner scanner = new Scanner(System.in);[m
[32m+[m[32m int number = 0;[m
[32m+[m[32m int pageNumber = 0;[m
[32m+[m[32m int totalNumber = 50;[m
while(true){[m
System.out.print("Enter records per page (1-50): ");[m
[32m+[m[32m number = scanner.nextInt();[m
[32m+[m[32m if (number < 1 || number > 50){[m
[32m+[m[32m System.out.println("无效输入");[m
[32m+[m[32m continue;[m
[32m+[m[32m }[m
[32m+[m[32m int maxPageNumber = (totalNumber + number - 1) / number;[m
[32m+[m[32m pageNumber = scanner.nextInt();[m
[32m+[m[32m if (pageNumber < 1 || pageNumber > maxPageNumber){[m
[32m+[m[32m System.out.println("无效输入,请重新输入");[m
[32m+[m[32m continue;[m
[32m+[m[32m }[m
// 补充逻辑[m
}[m
}[m
[1mdiff --git a/while_and_if/practices_while/ControlUserRegistrationSystem.java b/while_and_if/practices_while/ControlUserRegistrationSystem.java[m
[1mindex f3789a7..19b73ec 100644[m
[1m--- a/while_and_if/practices_while/ControlUserRegistrationSystem.java[m
[1m+++ b/while_and_if/practices_while/ControlUserRegistrationSystem.java[m
[36m@@ -18,6 +18,12 @@[m [mimport java.util.Scanner;[m
public class ControlUserRegistrationSystem {[m
public static void main(String[] args) {[m
Scanner scanner = new Scanner(System.in);[m
[32m+[m[32m String username ;[m
[32m+[m[32m String password ;[m
[32m+[m[32m while (true){[m
[32m+[m[32m System.out.println("请输入用户名(3-15个字符,只能包含字母):");[m
[32m+[m[32m username = scanner.nextInt();[m
[32m+[m[32m }[m
// 补充代码[m
}[m
}[m
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。