package test_33
import scala.io.Source
//成绩分析
object test {
def main(args: Array[String]): Unit = {
//1.读入成绩,按行去读取
val it= Source.fromFile("score.txt").getLines().drop(1)
while (it.hasNext){
val content=it.next()
//使用中文的逗号去拆分字符串
var arr=content.split(",")
val name=arr(0)
val yuwen=arr(1).toInt
val shuxue=arr(2).toInt
val yingyu=arr(3).toInt
val total=yuwen+shuxue+yingyu
val avg=total / 3
println("当前行是",name,yingyu,total)
}
}
}
Scala中字符串
爱吃香菜---www2024-11-28 14:28
相关推荐
踩着两条虫6 小时前
「AI + 低代码」的可视化设计器JoneBB7 小时前
ABAP Webservice连接Spider Cat 蜘蛛猫7 小时前
Springboot SSO系统设计文档即使再小的船也能远航7 小时前
【Python】安装Irissgwe7 小时前
类与对象(三)雪度娃娃8 小时前
转向现代C++——优先选用nullptr而不是0和NULLzyk_computer8 小时前
AI 时代,或许 Rust 比 Python 更合适萌新小码农8 小时前
python装饰器KK溜了溜了8 小时前
Python从入门到精通雨辰AI8 小时前
SpringBoot3 项目国产化改造完整流程|从 MySQL 到人大金仓落地