




已阅读5页,还剩10页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
攀枝花学院实验报告实验课程: Visual C#,NET程序设计 实验项目: 上机实验1 上机实验2 实验日期:2015 系:数学与计算机学院 班级: 2013级计算机科学与技术 姓名: 何静 学号: 201310801009 同组人: 指导教师:罗明刚 成绩:实验目的:1. ;理解c#的值类型,常量和变量的概念.2. 掌握c#常用运算符以及表达式的运算规则.3. 理解数据类型转换的方法.4. 掌握数组和字符串的使用方法.实验仪器设备,药品,器材:Microsoft visual studio 20101. 实验原理:熟悉visual 2010的基本操作方法.2. 认真阅读本章相关内容,尤其是案例.3. 实验前进行程序设计,完成源程序的编写任务.4. 反复操作,直到不需要参考教材,能熟练操作为止.实验步骤:见下页一.实验目的5. ;理解c#的值类型,常量和变量的概念.6. 掌握c#常用运算符以及表达式的运算规则.7. 理解数据类型转换的方法.8. 掌握数组和字符串的使用方法.2. 实验要求5. 熟悉visual 2010的基本操作方法.6. 认真阅读本章相关内容,尤其是案例.7. 实验前进行程序设计,完成源程序的编写任务.8. 反复操作,直到不需要参考教材,能熟练操作为止.3. 实验内容1. 设计一个简单的windows应用程序,完成以下功能:从键盘输入摄氏温度值,输出对应的华氏温度值.运行效果如图所示.摄氏温度到华氏温度的转换公式为: Fahrenheir=9/5celsius+32核心代码如下:double c = Convert.ToDouble(txtCelsius.Text);double f = 9 / 5 * c + 32;txtFahrenheir.Text = f.ToString();.2. 设计一个简单的储蓄存款计算器,运行效果如图所示.核心代码如下:int money = Convert.ToInt32(txtmoney.Text);int year = Convert.ToInt32(txtyear.Text);double rate = Convert.ToDouble(txtrate.Text) / 100;double interest = money * year * rate;txtinterest.Text = interest.ToString();double total = money + interest;txttotal.Text = total.ToString();3. 设计一个简单的windows程序,输入5个数字,然后排序输出,运行果如图所示.核心代码如下:double a = new double5;int i = 0;private void button1_Click(object sender, EventArgs e)double element = double.Parse(txtelement.Text);ai = element;txtprior.Text += ai + ;i+;lblNo.Text = 第输入第 + (i + 1) + 个元素;private void button2_Click(object sender, EventArgs e)Array.Sort(a);txtsort.Text = a0 + + a1 + + a2 + + a3 + + a4;4. 源程序1.using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace _2 public partial class Form1 : Form public Form1() InitializeComponent(); private void button1_Click(object sender, EventArgs e) if (txtc.Text != string.Empty) double c = Convert.ToDouble(txtc.Text); double f = 9 / 5 * c + 32; txtf.Text = f.ToString(); else if (txtf.Text != string.Empty) double f = Convert.ToDouble(txtf.Text); double c = (f - 32) * 5 / 9; txtc.Text = c.ToString(); 程序运行结果:2.using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace _3 public partial class Form1 : Form public Form1() InitializeComponent(); private void button1_Click(object sender, EventArgs e) int money = Convert.ToInt32(txtmoney.Text); int year = Convert.ToInt32(txtyear.Text); double rate = Convert.ToDouble(txtrate.Text) / 100; double interest = money * year * rate; txtinterest.Text = interest.ToString(); double total = money + interest; txttotal.Text = total.ToString(); 程序运行结果:3.using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace _4 public partial class Form1 : Form public Form1() InitializeComponent(); private void Form1_Load(object sender, EventArgs e) private void linkLabel1_LinkClicked(object sender,LinkLabelLinkClickedEventArgs e) private void labNo_Click(object sender, EventArgs e) private void label3_Click(object sender, EventArgs e) double a = new double5; int i = 0; private void button1_Click(object sender, EventArgs e) double element = double.Parse(txtelement.Text); ai = element; txtprior.Text += ai + ; i+; lblNo.Text = 第输入第 + (i + 1) + 个元素; private void button2_Click(object sender, EventArgs e) Array.Sort(a); txtsort.Text = a0 + + a1 + + a2 + + a3 + + a4; 1. 实验目的1. 理解分支和循环的逻辑意义2. 掌握c#的if,switch分支语句的使用方法.3. 掌握c#的while,do/while,for,foreach等循环语句的使用方法.二.实验要求9. 熟悉visual 2010的基本操作方法.10. 认真阅读本章相关内容,尤其是案例.11. 实验前进行程序设计,完成源程序的编写任务.12. 反复操作,直到不需要参考教材,能熟练操作为止.3. 实验内容1. 有一个函数: x (x1) Y= 2*x-1 (1x10) 3*x-11 (x10)设计一个windows应用程序,输入x,输出y值.核心代码提示如下:double x = Convert.ToDouble(txtx.Text);double y;if (x = 1 & x 0)turnnum = turnnum * 10 + num % 10;num = num / 10;txtn.Text = turnnum.ToString();3. 一个数如果恰好等于她的因子之和,这个数就称为完数.例如6的因子是1,2,3,而6=1+2+3,因此6是完数,编程找出1000之内的所有完数,当单击查找按钮时,按下面的格式输出所有完数和其因子:”6是一个完数:6=1+2+3”,如图所示:核心代码部分提示如下:StringBuilder sb = new StringBuilder();int i, j, sum;for (i = 2; i 1000; i+)sum = 0;for (j = i; j i / 2; j+)if (i % j = 0) sum += j;if (sum = i)sb.Append(i + 是一个完数: + i + =1);for (j = 2; j = i / 2; j+)if (i % j = 0)sb.Append(+ + j);sb.Append(n);lblshow.Text = sb.ToString();4. 源程序1.using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace _5 public partial class Form1 : Form public Form1() InitializeComponent(); private void button1_Click(object sender, EventArgs e) double x = Convert.ToDouble(txtx.Text); double y; if (x = 1 & x 0) turnnum = turnnum * 10 + num % 10; num = num / 10; txtn.Text = turnnum.ToString(); 运行结果如下:3.using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace _8 public partial class Form1 : Form public Form1() InitializeComponent(); private void button1_Click(object sender, EventArgs e) StringBuilder sb = new StringB
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- Lesson 4 A birthday card教学设计-2025-2026学年初中英语冀教版2024七年级上册-冀教版2024
- 4.6 汽化与液化第二课时说课稿-2025-2026学年浙教版七年级上册科学
- 2025年中考化学试题分类汇编:常见仪器及基本操作(第1期)解析版
- 第三节 可再生资源的利用与保护-以土地资源为例说课稿-2025-2026学年高中地理湘教版选修Ⅵ环境保护-湘教版2004
- 蓄电池的结构组成
- 2025年天津市河西区中考二模物理试题(解析版)
- 蓄电池安全管理课件
- 蓄电池基本知识课件
- 2025年山东省青岛市中考化学试题(含答案)
- 2025年人教版八年级英语上册各单元词汇知识点和语法讲解与练习(有答案详解)
- 生物制造中试能力建设平台培育指南(2025版)
- 2025年学宪法、讲宪法知识竞赛题库及答案
- (高清版)DB62∕T 4704-2023 医养结合机构基本服务规范
- 成人颈椎损伤急诊诊治专家共识解读
- DB32T 5124.2-2025 临床护理技术规范 第2部分:成人危重症患者无创腹内压监测
- (高清版)DB13(J)∕T 8557-2023 建设工程消耗量标准及计算规则(房屋修缮建筑工程)
- 自然灾害防治与应急管理培训
- 公司政治监督工作方案
- DB42T-湖北省既有建筑幕墙可靠性鉴定技术规程
- 大中型企业安全生产标准化管理体系要求解读2025
- 消除艾滋病、梅毒和乙肝母婴传播项目工作制度及流程(模板)
评论
0/150
提交评论