1、net程序设计实验二C#编程基础成绩批阅日期台州学院电子与信息工程学院实验报告班级 学号 姓名 吴前斌 同组 实验课程: .net程序设计 实验项目: C#编程基础 实验日期: 2019 年 3 月 12 日图2-1图2-2图2-3图2-4图2-5实验2-3 设计一个简单的商场收费程序。设某商场提供六种商品(编号为001-006),且规定一次购物满100元可享受9折优惠;一次购物满300元可享受8.5折优惠;一次购物在300元以上可享受8折优惠。客户购物付款时仅需要连续输入所购商品编号和数量,程序能自动显示购物清单和折扣率和应付金额。具体要求如下:1) 若没有输入商品数量,则默认为1。2) 若
2、没有输入商品的编号,直接单击“确定”按钮,则表示统计完毕,屏幕上显示购物金额、折扣率和应付金额。3) 单击“返回”按钮清楚上次购物详细清单及结算数据,将程序恢复到初始状态。程序运行后显示图2-6所示的页面,在输入了“编号”和“数量”后单击“确定”按钮,在屏幕上显示包含有“品名”、“单价”、“数量”和“小计”的购物详细清单。如果没有输入商品编号直接单击“确定”按钮,在购物清单下方将显示包含“购物金额”、“折扣”和“应付款”的结算数据,如图2-7所示。 教师签名:图2-6图2-7实验2-4 设计一个能计算1!+2!+3!+n!的程序。设计一个能计算1!+2!+3!+n!的程序,程序启动后显示图2-
3、8所示的界面,用户输入了一个正整数n后,单击“确定”按钮,窗体中显示出算式和阶乘和的计算结果。如果用户没有输入数据或输入了0,单击“确定”按钮时程序能给出图2-9所示的错误提示。图2-8图2-9实验2-5 设计一个三角函数计算器。设计一个根据用户输入的角度值计算三角函数值的应用程序。程序启动后显示图2-10所示的界面,用户在输入了角度值,选择了三角函数名称后单击“确定”按钮,窗体上将显示出相应的计算结果。图2-10四、实验步骤及结果记录(文字说明、关键代码配截图)五、实验小结(实验过程中遇到哪些问题,你是如何解决的,哪些知识点是你学习中的难点)六、源程序(和实验报告一起打包上交,打包文件命名:
4、学号姓名.net程序设计实验2) 教师签名: 实验2-11) 运行结果如下图所示:实现代码如下:2) 运行结果如下图所示: 实现代码如下:3) 运行结果如下图所示:实现代码如下:4) 运行结果如下图所示: 实现代码如下:5) 运行结果如下图所示:实现代码如下:6) 运行结果如下图所示:实现代码如下:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ConsoleApplication3 class Pro
5、gram static void Main(string args) Console.ForegroundColor = ConsoleColor.Yellow; Console.Write( _(_)_); Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine( wWWWw); Console.ForegroundColor = ConsoleColor.Red; Console.Write( ); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write(
6、 (_); Console.ForegroundColor = ConsoleColor.Red; Console.Write(); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write(_) ); Console.ForegroundColor = ConsoleColor.Blue; Console.Write(vVVVv ); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write(_ ); Console.ForegroundColor = Consol
7、eColor.Red; Console.Write( ); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine( (_); Console.ForegroundColor = ConsoleColor.Red; Console.Write( ); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write(); Console.ForegroundColor = ConsoleColor.Red; Console.Write(); Console.Fore
8、groundColor = ConsoleColor.Blue; Console.Write( wWWWWw ); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write(_); Console.ForegroundColor = ConsoleColor.Green; Console.Write( ); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write(_) _(_)_ ); Console.ForegroundColor = ConsoleColor.R
9、ed; Console.Write( ); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write(); Console.ForegroundColor = ConsoleColor.Red; Console.Write(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine( Y); Console.ForegroundColor = ConsoleColor.Red; Console.Write( ); Console.ForegroundColo
10、r = ConsoleColor.Yellow; Console.Write( (_) ); Console.ForegroundColor = ConsoleColor.Green; Console.Write( |/ Y ); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write(_); Console.ForegroundColor = ConsoleColor.Red; Console.Write(); Console.ForegroundColor = ConsoleColor.Yellow; Console.Wri
11、te(_); Console.ForegroundColor = ConsoleColor.Red; Console.Write( ); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine( |/); Console.ForegroundColor = ConsoleColor.Green; Console.Write( / Y | |/ /); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write(_) ); Console.ForegroundCo
12、lor = ConsoleColor.Green; Console.WriteLine( | |/); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine( | |/ | /| / |/ |/ |); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine( |/ |/ |/|/|/ |/ |/); Console.ForegroundColor = ConsoleColor.White; Console.Write(); Console.Fore
13、groundColor = ConsoleColor.Yellow; Console.Write( 百 ); Console.ForegroundColor = ConsoleColor.White; Console.Write(); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write( 花 ); Console.ForegroundColor = ConsoleColor.White; Console.Write(); Console.ForegroundColor = ConsoleColor.Yellow; Conso
14、le.Write( 园 ); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(); Console.ReadKey(); 实验2-2实验结果如下图1、图2、图3、图4:图1图2图3图4 运行的代码如下:日期时间+数字+字符串+随机数的代码: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 WindowsForm
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1