求用VS2008并用C#编写一个简单的银行利息计算器,利率0.5%,输入存款金额和天数,显示利息和本息
您好。不太明白您的意思。关于银行利息计算器,可以在各大银行官网中找到,计算也挺方便的。银行官网中不仅有个人存款计算器,并且还有个人贷款计算器、基金买卖计算器、股票买卖计算器。
b/s还是c/s?
如图:勾选了年利率则按年利率计算,存款天数会折算为年限。否则按日利率计算。
代码如下:
using System;using System.Windows.Forms;
namespace BankLiLv
{
public partial class Form1 : Form
{
#region === 必须的窗体变量 ===
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.textBox4 = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.textBox5 = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(87, 52);
this.textBox1.MaxLength = 6;
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(102, 21);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "0.5";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(87, 94);
this.textBox2.MaxLength = 20;
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(184, 21);
this.textBox2.TabIndex = 0;
this.textBox2.Text = "10000";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(87, 132);
this.textBox3.MaxLength = 10;
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(184, 21);
this.textBox3.TabIndex = 0;
this.textBox3.Text = "365";
//
// button1
//
this.button1.Location = new System.Drawing.Point(114, 267);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "(&C)计算";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 55);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(59, 12);
this.label1.TabIndex = 2;
this.label1.Text = "利 率:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 97);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(59, 12);
this.label2.TabIndex = 2;
this.label2.Text = "本 金:";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(13, 135);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(65, 12);
this.label3.TabIndex = 2;
this.label3.Text = "存款天数:";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(12, 193);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(59, 12);
this.label4.TabIndex = 4;
this.label4.Text = "利 息:";
//
// textBox4
//
this.textBox4.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.textBox4.Location = new System.Drawing.Point(87, 190);
this.textBox4.Name = "textBox4";
this.textBox4.ReadOnly = true;
this.textBox4.Size = new System.Drawing.Size(184, 21);
this.textBox4.TabIndex = 3;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(12, 224);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(59, 12);
this.label5.TabIndex = 6;
this.label5.Text = "本 息:";
//
// textBox5
//
this.textBox5.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.textBox5.Location = new System.Drawing.Point(87, 221);
this.textBox5.Name = "textBox5";
this.textBox5.ReadOnly = true;
this.textBox5.Size = new System.Drawing.Size(184, 21);
this.textBox5.TabIndex = 5;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label6.ForeColor = System.Drawing.Color.Red;
this.label6.Location = new System.Drawing.Point(198, 52);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(25, 22);
this.label6.TabIndex = 6;
this.label6.Text = "%";
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Checked = true;
this.checkBox1.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBox1.Location = new System.Drawing.Point(229, 54);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(60, 16);
this.checkBox1.TabIndex = 7;
this.checkBox1.Text = "年利率";
this.checkBox1.UseVisualStyleBackColor = true;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 318);
this.Controls.Add(this.checkBox1);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.textBox5);
this.Controls.Add(this.label4);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.MaximizeBox = false;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Form1";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox textBox5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.CheckBox checkBox1;
#endregion
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string temLiLv = this.textBox1.Text.Trim();
string temBenJin = this.textBox2.Text.Trim();
string temDays = this.textBox3.Text.Trim();
if (string.IsNullOrEmpty(temLiLv))
{
MessageBox.Show("利率不能为空!");
textBox1.Focus();
return;
}
if (string.IsNullOrEmpty(temBenJin))
{
MessageBox.Show("本金不能为空!");
textBox2.Focus();
return;
}
if (string.IsNullOrEmpty(temDays))
{
MessageBox.Show("存款天数不能为空!");
textBox3.Focus();
return;
}
decimal lilv = Convert.ToDecimal((temLiLv)) / 100;
decimal benjin = Convert.ToDecimal(temBenJin);
int days = Convert.ToInt32(temDays); //Math.Floor(Convert.ToDouble(temDays));
decimal lixi;
if (checkBox1.Checked)
{
int year = days / 365;
lixi = benjin * lilv * year;
}
else
{
lixi = benjin * lilv * days;
}
textBox4.Text = lixi.ToString();
textBox5.Text = (benjin + lixi).ToString();
}}
}
我没有winfrom的程序,我那Webfrom给你写吧,代码是一样的
本金
int n = Convert.ToInt32(this.TextBox1.Text.Trim());
利率 int m = Convert.ToInt32(this.TextBox2.Text.Trim());
利息 this.TextBox3.Text = ("本金×年利率(百分数)×存期");
Conscle.WileLine("利率计算器”);
Conscle.Write(输入本金);
intPrincipal = intParse(Censole ReadLine0);
Console.Wite("输入存款天数:");
intday= int.Parse(ConsoleReadLine());
double PAI= Principal *(1 + nterestRat * day /365);
double Interest = Principal * (InterestRate , dey /365);
Conscle.Writel ine("利息"+ Interest.ToString() + "\n" +"本息"+ PAl.ToSting());
Conscle. ReadLine():
两个文本框,再转换成数值,再计算就行了.
求用VS2008并用C#编写一个简单的银行利息计算器,利率0.5%,输入存款金额...
利息this.TextBox3.Text = ("本金×年利率(百分数)×存期"); 追问 不行啊,我用VS2008运行不对啊 追答 加我QQ,909588372我给你远程 已赞过 已踩过< 你对这个回答的评价是? 评论 收起 __WANGLIAN 2018-12-06 知道答主 回答量:1 采纳率:0% 帮助的人:450 我也去答题访问个人页 关注...
vs2008和vs2010两个版本都用,会不会有冲突?
VS2010里面有几个.NETFramwork4.0、3.5、2.0,在新建项目或者网站时,只需选择.NETFramwork3.5一下的版本即可,这样VS2008就能打开VS2010里面的程序。
VS2008怎么用??
2. 代码编写与调试:在VS2008的代码编辑器中,用户可以编写代码。编辑器提供了语法高亮、代码补全和智能感知等功能,帮助用户更高效地编写代码。同时,VS2008还提供了强大的调试工具,允许用户在运行时检查和修改代码,帮助发现和解决问题。3. 界面设计与布局:对于Windows桌面应用程序,用户需要使用Windows窗...
VS2008 使用窗体编程程序 如何添加资源文件并使用
由于对称关系和A(i,i) 为 0,输入只给出矩阵的下三角。第一行A(1,1)在输入中省略,第二行只有A(2,1),下一行则是A(3,1) 和A(3,2),依此类推。
vs2008和vs2012能不能在同一台机器上共存?如果可以,会不会有冲突?如何...
可以在同一台电脑上安装2个版本,但要注意版本间的转换问题。比如项目A是用VS2008创建的,可以用VS2012打开编辑。而项目B是用VS2012创建的,用VS2008是打不开的。建议你去下载一个VS版本转换器,很有用的,也很方便。
如何用VS2008将几个项目集成到一个项目里
几个项目集成到一个解决方案下 新键一个项目如果显示无解决方案的话vs2008工具 选项 项目与解决方案总是显示解决方案 解决方案上点右键添加 项目有项目OK
如何使用vs 2008 连接wec 7进行调试
工具\/原料 Wince 5.0模拟器安装包 VS2008操作平台 Windows Mobile设备中心 方法\/步骤 1 打开Wince模拟器,选择所需的屏幕分辨率 2 Wince模拟器中 点击【开始】---【设置】---【网络和拨号连接】点击【新建连接】选择【直接连接】点击【下一步】选择【Serial over DMA】点击【完成】
VS2008怎么用??
1、运行VS2008,打开一个项目或者工作空间。2、单击菜单栏中的【工具】,单击弹出菜单中的【选项】。3、在左侧树形列表中的,找到【环境】\\【字体和颜色】在右侧 选择【显示其位置】:文本编辑器;在右侧 选择【显示项】下各个条目,根据条目选择其 项前景色(字体颜色)、 项后景色(背景色)、粗体...
怎么在VS2008里使用jsoncpp
方法一:直接拷贝源文件。这个方法比较简单,但不推荐,因为不便于项目管理。VS2008里新建一个空的控制台程序(用作测试jsoncpp是否可用),名为: TestJSON 解压下载好的文件:jsoncpp-src-0.5.0.tar.gz 将 jsoncpp-src-0.5.0\\include 目录下的json文件夹拷贝至 TestJSON 工程目录下 将 jsoncpp-src...
在VS2008平台使用C#开发winform,实现浏览网页计算耗时和速率_百度知 ...
可通过下面的方法访问一个任意的网址,然后用response讲流保存到一个位置,在开始访问之前进行计时,保存流完成之后停止计时。流的大小除以所用时间久可以计算出你想要的数据来。反正根据各种计算公式可以将每秒下载的字节数转换为各种传输速率。这种是比较笨的办法,但是可能是最好理解的方法。希望能帮助你。
昔要瑞平: 朋友,我举个简单的例子给你吧. 一、编写c#控制台应用程序.打开vs,选择【文件】-【新建】-【项目】,就会弹出【新建项目】对话框,在【项目类型】中,选择要编写的语言(如visual c#),再选择“windows”,在右边选择“控制台应...
前郭尔罗斯蒙古族自治县13539956270: 在visual studio 2008里用c#开发一个简单的C/S模式的管理信息系统 - ?
昔要瑞平: 呵呵,问题还真多呢,做B/S模式开发C/S模式应该很容易理解的,建议找本书看看,新建一个项目只建一个form窗体就好,access数据库一般放在data文件里面,移植的话建议选好目录,数据库连接可以在config文件里面写,一般项目的话会写一个DBhelp,发布vs2008自带有部署文件的
前郭尔罗斯蒙古族自治县13539956270: 怎么用c#语言在VS2008环境下编写这个程序.?
昔要瑞平:namespace StudentTest { public static class Program { public static List<Student> stuList = new List<Student>(); public static void Main(string[] args) { //添加学生 setScore("张三", 100); setScore("李四", 80); int _avgScore = 0; ...
前郭尔罗斯蒙古族自治县13539956270: vs2008如何编译c# - ?
昔要瑞平: 看你是想编写控制台应用程序,还是窗体应用程序.因为初学者编者两种最常见. 1.如果是前者步骤是:选择“文件”,“新建”,“项目”,出现项目对话框,在左边选择visual C#,右边选第四个即选择“文件”,“新建”,“项目”,出现项目对话框,在左边选择visual C#,即控制台应用程序. 2.如果是后者:选择“文件”,“新建”,“项目”,出现项目对话框,在左边选择visual C#,右边选第一项即Windows 窗体应用程序!!!——祝你成功 补充一下,变写代码后,在菜工具栏的中间位置 有一个绿色的小三角,点之即可运行程序.
前郭尔罗斯蒙古族自治县13539956270: 小弟刚学C #,请问在VS2008中怎样编写最简单的~hello word~的C#程序,新建项目,那些程序类型怎么选择啊 - ?
昔要瑞平: Console Application1. 初学者 public class HelloWorld { public static void Main() { System.Console.WriteLine("HELLO WORLD"); } }2. 改进的HELLO WORLD using System; public class HelloWorld { public static void Main() { Console.WriteLine...
前郭尔罗斯蒙古族自治县13539956270: 如何用C#写一个插件(VS2008) - ?
昔要瑞平: using System; namespace PluginA { public class PluginA : PluginInterface.IShow { public string Show() { return "I am plugin A" ; } } } 以上是随便一个类 继承接口 PluginInterface.IShow using System; namespace PluginInterface { public interface ...
前郭尔罗斯蒙古族自治县13539956270: VS2008初学,语言用C#,求代码与解释. - ?
昔要瑞平: aspx:<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:Timer ID="Timer1" Interval="2000" runat="server" ontick="Timer1_Tick"> </asp:Timer>.cs:using System;public partial class test_时间显...
前郭尔罗斯蒙古族自治县13539956270: 如何在VS2008下新建并编码一个C#程序! 中文版?
昔要瑞平: 在vs解决方案上右击,发布.
前郭尔罗斯蒙古族自治县13539956270: 如何在vs2008中用C#语言实现查询功能? - ?
昔要瑞平: 用SQL语句来查; select * from 表名 where 地名地址字段名 like '%"&关键字&"%'
前郭尔罗斯蒙古族自治县13539956270: 谁知道怎么用VS2008运行C#??? - ?
昔要瑞平: 操作和vs2005不会有太大区别. vs不能直接运行编译一个c#文件,而是先要建一个project,在这个project中,建一个c#文件,运行你的代码才可以. 回复:你不建project,点任何按钮都不起作用.等建好project,把代码放进去,按钮很好找的,多试试. 如果嫌麻烦,我告诉你快捷键: ctrl+F5:运行但不调试 F5:调试 shift+F5:停止调试 F10:逐句调试 F11:过程调试.