程序50

/*
题目:有五个学生,每个学生有3门课的成绩,从键盘输入以上数据(包括学生号,姓名,三门课成绩),
计算出平均成绩,况原有的数据和计算出的平均分数存放在磁盘文件"stud"中。
*/

import java.util.*;
import java.io.*;
public class Example50{
	public static void main(String args[]) throws IOException{
		Scanner sc=new Scanner(System.in);
		System.out.print("请输入第一个学生的学号、姓名和三门课成绩:");
		String str1=sc.next();
		String[] arr1=str1.split("\\,");
		System.out.print("请输入第二个学生的学号、姓名和三门课成绩:");
		String str2=sc.next();
		String[] arr2=str2.split("\\,");
		System.out.print("请输入第三个学生的学号、姓名和三门课成绩:");
		String str3=sc.next();
		String[] arr3=str3.split("\\,");
		//第一个学生平均分计算
		int sum1=0;
		for(int i=2;i<arr1.length;i++){
			sum1=sum1+Integer.parseInt(arr1[i]);
		}
		double avg1=(double)sum1/3;
		//第二个学生平均分计算
		int sum2=0;
		for(int i=2;i<arr2.length;i++){
			sum2=sum2+Integer.parseInt(arr2[i]);
		}
		double avg2=(double)sum2/3;
		//第三个学生平均分计算
		int sum3=0;
		for(int i=2;i<arr3.length;i++){
			sum3=sum3+Integer.parseInt(arr3[i]);
		}
		double avg3=(double)sum3/3;

		//写入到文件中
		BufferedWriter bw = new BufferedWriter(new FileWriter("h:\\stud.txt")); 
		bw.write(str1);
		bw.write("  平均分:" + avg1);
		bw.write("\r\n");
		bw.write(str2);
		bw.write("  平均分:" + avg2);
		bw.write("\r\n");
		bw.write(str3);
		bw.write("  平均分:" + avg3);
		bw.flush();//清空缓存
		bw.close();//输出流关闭
	}
}

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
很抱歉,我无法提供完整的微信小程序50个api和组件用法及案例代码。但是,我可以给你提供一些常用的微信小程序api和组件及其简单用法: 1. wx.request() - 发起网络请求 ``` wx.request({ url: 'url', data: {}, header: {}, method: 'GET/POST/PUT/DELETE', dataType: 'json', responseType: 'text', success: function(res) {}, fail: function(res) {}, complete: function(res) {}, }) ``` 2. wx.navigateTo() - 跳转到页面 ``` wx.navigateTo({ url: 'url' }) ``` 3. wx.showLoading() - 显示加载提示框 ``` wx.showLoading({ title: 'loading', mask: true, }) ``` 4. wx.hideLoading() - 隐藏加载提示框 ``` wx.hideLoading() ``` 5. wx.showToast() - 显示消息提示框 ``` wx.showToast({ title: 'message', icon: 'success/warning/none', duration: 2000, }) ``` 6. wx.showModal() - 显示模态框 ``` wx.showModal({ title: 'title', content: 'content', showCancel: true, cancelText: 'cancel', confirmText: 'confirm', success: function(res) {}, fail: function(res) {}, complete: function(res) {}, }) ``` 7. wx.getStorageSync() - 同步获取本地据缓存 ``` wx.getStorageSync('key') ``` 8. wx.setStorageSync() - 同步设置本地据缓存 ``` wx.setStorageSync('key', 'value') ``` 9. wx.createAnimation() - 创建动画实例 ``` var animation = wx.createAnimation({ duration: 1000, timingFunction: 'ease', delay: 0, transformOrigin: '50% 50% 0', }) ``` 10. wx.createCanvasContext() - 创建画布上下文 ``` var context = wx.createCanvasContext('canvas') ``` 以上是一些常用的微信小程序api和组件及其简单用法,希望对你有所帮助。如果需要更详细的内容和案例代码,建议你去官方文档查阅。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值