12 changed files with 113 additions and 0 deletions
@ -0,0 +1,30 @@ |
|||
### IntelliJ IDEA ### |
|||
out/ |
|||
!**/src/main/**/out/ |
|||
!**/src/test/**/out/ |
|||
.kotlin |
|||
|
|||
### Eclipse ### |
|||
.apt_generated |
|||
.classpath |
|||
.factorypath |
|||
.project |
|||
.settings |
|||
.springBeans |
|||
.sts4-cache |
|||
bin/ |
|||
!**/src/main/**/bin/ |
|||
!**/src/test/**/bin/ |
|||
|
|||
### NetBeans ### |
|||
/nbproject/private/ |
|||
/nbbuild/ |
|||
/dist/ |
|||
/nbdist/ |
|||
/.nb-gradle/ |
|||
|
|||
### VS Code ### |
|||
.vscode/ |
|||
|
|||
### Mac OS ### |
|||
.DS_Store |
|||
@ -0,0 +1,10 @@ |
|||
# 默认忽略的文件 |
|||
/shelf/ |
|||
/workspace.xml |
|||
# 已忽略包含查询文件的默认文件夹 |
|||
/queries/ |
|||
# Datasource local storage ignored files |
|||
/dataSources/ |
|||
/dataSources.local.xml |
|||
# 基于编辑器的 HTTP 客户端请求 |
|||
/httpRequests/ |
|||
@ -0,0 +1,6 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project version="4"> |
|||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="21" project-jdk-type="JavaSDK"> |
|||
<output url="file://$PROJECT_DIR$/out" /> |
|||
</component> |
|||
</project> |
|||
@ -0,0 +1,8 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project version="4"> |
|||
<component name="ProjectModuleManager"> |
|||
<modules> |
|||
<module fileurl="file://$PROJECT_DIR$/w7.iml" filepath="$PROJECT_DIR$/w7.iml" /> |
|||
</modules> |
|||
</component> |
|||
</project> |
|||
@ -0,0 +1,6 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project version="4"> |
|||
<component name="VcsDirectoryMappings"> |
|||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" /> |
|||
</component> |
|||
</project> |
|||
@ -0,0 +1,5 @@ |
|||
90 |
|||
99 |
|||
100 |
|||
98 |
|||
96 |
|||
@ -0,0 +1,37 @@ |
|||
import java.io.BufferedReader; |
|||
import java.io.FileReader; |
|||
import java.io.IOException; |
|||
|
|||
public class Main { |
|||
public static void main(String[] args) { |
|||
int sum = 0; |
|||
int count = 0; |
|||
try (BufferedReader br = new BufferedReader(new FileReader("scores.txt"))){ |
|||
String line; |
|||
while ((line = br.readLine())!= null){ |
|||
line = line.trim(); |
|||
if(line.isEmpty()){ |
|||
continue; |
|||
} |
|||
int score = Integer.parseInt(line); |
|||
sum +=score; |
|||
count++; |
|||
} |
|||
if (count > 0){ |
|||
double avg = (double)sum / count; |
|||
System.out.println("平均分:"+avg); |
|||
|
|||
} else { |
|||
System.out.println("文件中无有效成绩"); |
|||
} |
|||
} catch (NumberFormatException e){ |
|||
System.out.println("文字内容不是数字,无法转换为成绩"); |
|||
|
|||
} catch (java.io.FileNotFoundException e){ |
|||
System.out.println("错误,找不到scores.txt文件"); |
|||
} catch (IOException e){ |
|||
System.out.println("文件操作异常:"+e.getMessage()); |
|||
} |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<module type="JAVA_MODULE" version="4"> |
|||
<component name="NewModuleRootManager" inherit-compiler-output="true"> |
|||
<exclude-output /> |
|||
<content url="file://$MODULE_DIR$"> |
|||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> |
|||
</content> |
|||
<orderEntry type="inheritedJdk" /> |
|||
<orderEntry type="sourceFolder" forTests="false" /> |
|||
</component> |
|||
</module> |
|||
|
After Width: | Height: | Size: 217 KiB |
|
After Width: | Height: | Size: 258 KiB |
|
After Width: | Height: | Size: 190 KiB |
|
After Width: | Height: | Size: 255 KiB |
Loading…
Reference in new issue