为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

人民币大小写转换

2017-09-21 22页 doc 161KB 252阅读

用户头像

is_435706

暂无简介

举报
人民币大小写转换人民币大小写转换 成 绩 评 定 表 学生姓名 张建武 班级学号 1403050416 专 业 计算机科学与技术 课程设计题目 人民币大小写转 换 评 语 组长签字: 成绩 201 年 月 日 日期 课程设计任务书 学 院 信息科学与工程学院 专 业 计算机科学与技术 学生姓名 张建武 班级学号 1403050416 课程设计题目 文本分析 实践教学要求与任务: 输入一个钱数,比如3456.45,显示其人民币大写:叁仟肆佰伍拾陆元肆角伍分。用C#窗体程序实现,注意数字中带有零的情况,比如3009005.0...
人民币大小写转换
人民币大小写转换 成 绩 评 定 表 学生姓名 张建武 班级学号 1403050416 专 业 计算机科学与技术 课程设计题目 人民币大小写转 换 评 语 组长签字: 成绩 201 年 月 日 日期 课程设计任务书 学 院 信息科学与学院 专 业 计算机科学与技术 学生姓名 张建武 班级学号 1403050416 课程设计题目 文本 实践教学要求与任务: 输入一个钱数,比如3456.45,显示其人民币大写:叁仟肆佰伍拾陆元肆角伍分。用C#窗体程序实现,注意数字中带有零的情况,比如3009005.04。多试一些,确保你的程序可用于银行储蓄系统。 工作与进度安排: 第14周: 问题分析,设计,软件编码和调试; 第19周: 软件测试,书写课设,答辩。 指导教师: 专业负责人: 学院教学副院长: 201 年 月 日 201 年 月 日 201 年 月 日 一、实训题目和实训任务 二、1. 实训题目 人民币大小写转换 2. 实训任务 输入一个钱数,比如3456.45,显示其人民币大写:叁仟肆佰伍拾陆元肆角伍分。用C#窗体程序实现,注意数字中带有零的情况,比如3009005.04。多试一些,确保你的程序可用于银行储蓄系统。 3. 题目分析 刚选这道题目的时候我认为这个应该是挺简单的一道题,运用数组定义单位和大写字符。然后再通过循环来实现对数字的大写转换和单位的添加。所以应该只有一个关键的转换代码。可以让这个代码通过butto按钮实现转换。之后对这个代码多次进行调试确保可以识别所有数字和单位然后重复这个关键代码就可以实现识别位数的增加达到规定要求。然后在完成题目中其他要求比如对于零的处理,可以添加一个整形变量用来识别本位数是否为零,进而达到对零的识别。完成课题中所有的要求。其次添加一些别的简单的小功能比如类似计算器键盘的按钮的输入功能。添加数字输入按钮、转换按钮、清空按钮等功能按钮。这样可以使得程序更加丰满不会觉得太过于单调,使得界面更加丰满。之后再添加各种图片用来装饰整个程序。完成此程序。 4. 开发工具和环境 开发工具:Visual Studio 2012 环境:Windows 2000, XP, Vista等 二、软件设计 1. 关键技术分析 ?实现数值和单位赋值大代码 //定义单位,大写,和用于判断的c,i,j,n string[] a = { "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" }; string[] b = { "分", "角", "元", "十", "百", "千", "万", "十", "百", "千", "亿", "十", "百", "千" }; string c; int k = 0; int j; int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11; //输入数值i强制只能读到分位 double i = double.Parse(textBox1.Text); int n = (int)(100 * i); //实现分位数的单位与数值转换 a1 = j = n % 10; if (n != 0) { if (j != 0) { c = a[j - 1]; textBox2.Text = (c + b[k] + textBox2.Text); k++; } else { textBox2.Text = (textBox2.Text); k++; } } else { textBox2.Text = textBox2.Text; k++; } ?实现对零的判断代码 //个位数对于零的判断以及读法 if (a3== 0) { if (a2==0&&a3==0) { textBox2.Text = "元整" + textBox2.Text; } else textBox2.Text ="元零"+ textBox2.Text; } 2. 软件模块设计 总共14个button。其中10个位输入数字键按钮,1个位小数点,1个实现退格按钮,1个实现文本全部清空按钮,1个实现人民币转换按钮 总共两个label。用来标识两个Textbox的功能 总共2个Textbox,分别显示人民币金额和大写金额 3. 软件界面设计 三、软件测试及运行结果 1(测试方案 ?输入人民币金额为:3009005.04 程序运行结果应为:叁百万零万玖千零伍元肆分 ?输入:12345678.23 程序运行结果应为:壹千贰百叁十肆万伍千陆百柒十捌元贰角叁分 ?输入:10000 程序运行结果应为:壹万元整 ?输入12345678910 程序运行结果应为:超出范围! 2. 测试结果 ? ? ? ? 四、收获和体会 1(实习收获 通过这次课程设计,让我更加深刻了解课本知识,和以往对知识的疏忽得以补充,在设计过程中遇到一些模糊的公式和专业用语,比如if,else的嵌套,窗体应用控件的构建和程序语句的编排,但是这些问题经过这次设计,都一一得以解决,我相信这本书中还有很多我为搞清楚的问题,但是这次的课程设计给我相当的基础知识,为我以后工作打下了严实的基础。 虽然这次课程是那么短暂的2周时间,我感觉到这些天我的所学胜过我这一学期所学,这次任务原则上是设计,其实就是一次大的作业,是让我对课本知识的巩固和对基本公式的熟悉和应用课程设计是培训学生运用本专业所学的理论知识和专业知识来分析解决实际问题的重要教学环节,是对本学期所学知识的复习和巩固。同样,也促使了同学们的相互探讨,相互学习。因此,我们必须认真、谨慎、踏实、一步一步的完成设计。 2. 实习体会 通过此次课程设计,使我更加扎实的掌握了有关方面的知识,在设计过程中虽然遇到了一些问题,但经过一次又一次的思考,一遍又一遍的检查终于找出了原因所在,也暴露出了前期我在这方面的知识欠缺和经验不足。实践出真知,通过亲自动手制作,使我们掌握的知识不再是纸上谈兵。 过而能改,善莫大焉。在课程设计过程中,我们不断发现错误,不断改正,不断领悟,不断获取。最终的检测调试环节,本身就是在践行“过而能改,善莫大焉”的知行观。这次课程设计终于顺利完成了,在设计中遇到了很多问题,最后在老师的指导下,终于游逆而解。在今后社会的发展和学习实践过程中,一定要不懈努力,不能遇到问题就想到要退缩,一定要不厌其烦的发现问题所在,然后一一进行解决,只有这样,才能成功的做成想做的事,才能在今后的道路上劈荆斩棘,而不是知难而退,那样永远不可能收获成功,收获喜悦,也永远不可能得到社会及他人对你的认可~ 五、源代码清单 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace 人民币大小写转换1403050216_ { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { try { //定义单位,大写,和用于判断的c,i,j,n string[] a = { "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", " 玖" }; string[] b = { "分", "角", "元", "十", "百", "千", "万", "十", " 百", "千", "亿", "十", "百", "千" }; string c; int k = 0; int j; int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11; //输入数值i强制只能读到分位 double i = double.Parse(textBox1.Text); int n = (int)(100 * i); //实现分位数的单位与数值转换 a1 = j = n % 10; if (n != 0) { if (j != 0) { c = a[j - 1]; textBox2.Text = (c + b[k] + textBox2.Text); k++; } else { textBox2.Text = (textBox2.Text); k++; } } else { textBox2.Text = textBox2.Text; k++; } //实现角位数的单位与数值转换 n = n / 10; a2 = j = n % 10; if (n != 0) { if (j != 0) { c = a[j - 1]; textBox2.Text = (c + b[k] + textBox2.Text); k++; } else { textBox2.Text = (textBox2.Text); k++; } } else { textBox2.Text = textBox2.Text; k++; } //实现个位数的单位与数值转换 n = n / 10; a3 = j = n % 10; if (n != 0) { if (j != 0) { c = a[j - 1]; textBox2.Text = (c + b[k] + textBox2.Text); k++; } else { textBox2.Text = (textBox2.Text); k++; } } else { textBox2.Text = textBox2.Text; k++; } //个位数对于零的判断以及读法 if (a3== 0) { if (a2==0&&a3==0) { textBox2.Text = "元整" + textBox2.Text; } else textBox2.Text ="元零"+ textBox2.Text; } //实现十元位数的单位与数值转换 n = n / 10; a4 = j = n % 10; if (n != 0) { if (j != 0) { c = a[j - 1]; textBox2.Text = (c + b[k] + textBox2.Text); k++; } else { textBox2.Text = (textBox2.Text); k++; } } else { textBox2.Text = textBox2.Text; k++; } //十元位数对于零的判断以及读法 if (a4 == 0) { if (a3 != 0) { textBox2.Text = "零" + textBox2.Text; } else textBox2.Text = textBox2.Text; } //实现百位数的单位与数值转换 n = n / 10; a5 = j = n % 10; if (n != 0) { if (j != 0) { c = a[j - 1]; textBox2.Text = (c + b[k] + textBox2.Text); k++; } else { textBox2.Text = (textBox2.Text); k++; } } else { textBox2.Text = textBox2.Text; k++; } //百位数对于零的判断以及读法 if (a5 == 0) { textBox2.Text = "" + textBox2.Text; } //实现千位数的单位与数值转换 n = n / 10; a6 = j = n % 10; if (n != 0) { if (j != 0) { c = a[j - 1]; textBox2.Text = (c + b[k] + textBox2.Text); k++; } else { textBox2.Text = (textBox2.Text); k++; } } else { textBox2.Text = textBox2.Text; k++; } //千位位数对于零的判断以及读法 if (a6 == 0) { textBox2.Text = "" + textBox2.Text; } //实现万位数的单位与数值转换 n = n / 10; a7 = j = n % 10; if (n != 0) { if (j != 0) { c = a[j - 1]; textBox2.Text = (c + b[k] + textBox2.Text); k++; } else { textBox2.Text = ("万" + textBox2.Text); k++; } } else { textBox2.Text = textBox2.Text; k++; } //万位数对于零的判断以及读法 if (a7 == 0) { textBox2.Text = "零" + textBox2.Text; } //实现十万位数的单位与数值转换 n = n / 10; a8 = j = n % 10; if (n != 0) { if (j != 0) { c = a[j - 1]; textBox2.Text = (c + b[k] + textBox2.Text); k++; } else { textBox2.Text = (textBox2.Text); k++; } } else { textBox2.Text = textBox2.Text; k++; } //十万数对于零的判断以及读法 if (a8 == 0) { if (a7 != 0) { textBox2.Text = "" + textBox2.Text; } else textBox2.Text = "万" + textBox2.Text; } //实现百万位数的单位与数值转换 n = n / 10; a9 = j = n % 10; if (n != 0) { if (j != 0) { c = a[j - 1]; textBox2.Text = (c + b[k] + textBox2.Text); k++; } else { textBox2.Text = (textBox2.Text); k++; } } else { textBox2.Text = textBox2.Text; k++; } //实现千万位数的单位与数值转换 n = n / 10; a10 = j = n % 10; if (n != 0) { if (j != 0) { c = a[j - 1]; textBox2.Text = (c + b[k] + textBox2.Text); k++; } else { textBox2.Text = (textBox2.Text); k++; } } else { textBox2.Text = textBox2.Text; k++; } //实现亿位数的单位与数值转换 n = n / 10; a11 = j = n % 10; if (n != 0) { if (j != 0) { c = a[j - 1]; textBox2.Text = (c + b[k] + textBox2.Text); k++; } else { textBox2.Text = (textBox2.Text); k++; } } else { textBox2.Text = textBox2.Text; k++; } } //错误提示超出数值范围 catch(Exception) {MessageBox.Show("超出范围~");}} //以上为人民币大小写转换核心程序 //以下为按钮输入按钮键的代码 //输入数值1 private void button2_Click(object sender, EventArgs e) { if (textBox1.Text == "0") textBox1.Text = "1"; else textBox1.Text += "1"; } //输入数值2 private void button3_Click(object sender, EventArgs e) { if (textBox1.Text == "0") textBox1.Text = "2"; else textBox1.Text += "2"; } //输入数值3 private void button4_Click(object sender, EventArgs e) { if (textBox1.Text == "0") textBox1.Text = "3"; else textBox1.Text += "3"; } //输入数值4 private void button5_Click(object sender, EventArgs e) { if (textBox1.Text == "0") textBox1.Text = "4"; else textBox1.Text += "4"; } //输入数值5 private void button6_Click(object sender, EventArgs e) { if (textBox1.Text == "0") textBox1.Text = "5"; else textBox1.Text += "5"; } //输入数值6 private void button7_Click(object sender, EventArgs e) { if (textBox1.Text == "0") textBox1.Text = "6"; else textBox1.Text += "6"; } //输入数值7 private void button8_Click(object sender, EventArgs e) { if (textBox1.Text == "0") textBox1.Text = "7"; else textBox1.Text += "7"; } //输入数值8 private void button9_Click(object sender, EventArgs e) { if (textBox1.Text == "0") textBox1.Text = "8"; else textBox1.Text += "8"; } //输入数值9 private void button10_Click(object sender, EventArgs e) { if (textBox1.Text == "0") textBox1.Text = "9"; else textBox1.Text += "9"; } //输入字符“.” private void button11_Click(object sender, EventArgs e) { string s = ""; bool c = false; for (int i = 0; i < textBox1.Text.ToString().Length; i++) { s = textBox1.Text.ToString().Substring(i, 1); if (s == ".") c = true; } if (!c) textBox1.Text += "."; else textBox1.Text += ""; } //输入数值0 private void button12_Click(object sender, EventArgs e) { if (textBox1.Text != "0") { textBox1.Text += "0"; } } //实现退格功能 private void button13_Click(object sender, EventArgs e) { string s = textBox1.Text.ToString(); string s1 = s.Substring(0, s.Length - 1); if (s1.Length == 0) textBox1.Text = "0"; else textBox1.Text = s1; } //实现复位功能 private void button14_Click(object sender, EventArgs e) { textBox1.Text = "0"; textBox2.Text = ""; } private void textBox1_TextChanged(object sender, EventArgs e) { } private void label1_Click(object sender, EventArgs e) { } private void label2_Click(object sender, EventArgs e) { } private void Form1_Load(object sender, EventArgs e) { } private void textBox2_TextChanged(object sender, EventArgs e) { } } } (换页) 参考文献 [1] 轻松学c#,谷涛、扶晓、毕国锋遍著,电子工业出版社. 2013.6[
/
本文档为【人民币大小写转换】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索