Search This Blog

Tuesday, 9 June 2015

A window application in which user enter 5 subject marks & print the grade of each student in a message box

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 WindowsFormsApplication1
{
   static void main()
{
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.Run(new Form1());
}}}
partial class Form1{
    private System.ComponentModel.IContainer components=null;
    protected override void Dispose(bool disposing){
        if(disposing &&(components!=null){
            components.Dispose();}
        base.Dispose(disposing);
    }
    private void InitializeComponent(){
        this.label1=new System.Windows.Forms.Label();
        this.button1=new System.Windows.Forms.Button();
         this.textbox2=new System.Windows.Forms.TextBox();
        this.textbox5=new System.Windows.Forms.TextBox();
        this.textbox4=new System.Windows.Forms.TextBox();
        this.textbox3=new System.Windows.Forms.TextBox();
        this.textbox1=new System.Windows.Forms.TextBox();
        this.SuspendLayout();
        this.label1.Font=new System.Drawing.Font("Arial Narrow",24F,System.Drawing.FontStyle.Bold,System.Drawing.GraphicsUnit.Point,((byte)(0)));
        this.label1.Location=new System.Drawing.Point(29,23);
        this.label1.Name="label1";
        this.label1.Size=new System.Drawing.Size(614,45);
        this.label1.TabIndex=14;
        this.label1.Text="Enter the marks for various subjects out of 100";
        this.label1.TextAlign=System.Drawing.ContentAlignment,MiddleCenter;
        this.button1.Location=new System.Drawing.Point(252,269);
        this.button1.Name="button1";
         this.button1.Size=new Systemm.Drawing.Size(148,58);
        this.button1.TabIndex="13";
         this.button1.Text="Show Grade";
        this.button1.UseVisualStyleBackColor=true;
        this.button1.Click+=new System.EventHandler(this.button1_Click);
        this.textBox2.Location=new System.Drawing.Point(252,109);
        this.textBox2.Multiline=true;
        this.textBox2.Name="textBox2";
        this.textBox2.RightToLeft=new System.Windows.Forms.RightToLeft.Yes;
        this.button2.Size=new System.Drawing.Size(148,31);
        this.textBox2.TabIndex=12;
        this.textBox5.Location=new System.Drawing.Point(348,31);
        this.textBox5.Multiline=true;
        this.textBox5.Name="textBox5";
        this.textBox5.RightToLeft=new System.Windows.Forms.RightToLeft.Yes;
        this.textBox5.Size=new System.Drawing.Size(148,31);
        this.textBox5.TabIndex=11;
         this.textBox4.Location=new System.Drawing.Point(151,180);
        this.textBox4.Multiline=true;
        this.textBox4.Name="textBox4";
        this.textBox4.RightToLeft=new System.Windows.Forms.RightToLeft.Yes;
           this.textBox4.Size=new System.Drawing.Size(148,31);
          this.textBox4.TabIndex=10;
         this.textBox3.Location=new System.Drawing.Point(438,109);
this.textBox3.Multiline=true;
        this.textBox3.Name="textBox3";
        this.textBox3.RightToLeft=new System.Windows.Forms.RightToLeft.Yes;
        this.textBox3.Size=new System.Drawing.Size(148,31);
         this.textBox3.TabIndex=9;
        this.textBox1.Location=new System.Drawing.Point(65,109);
        this.textBox1.Multiline=true;
        this.textBox1.Name="textBox1";
        this.textBox1.RightToLeft=new System.Windows.Forms.RightToLeft.Yes;
         this.button1.Size=new System.Drawing.Size(148,31);
         this.textBox1.TabIndex=8;
        this.AutoScaleDimensions=new System.Drawing.SizeF(6F,13F);
        this.AutoScaleMode=System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize=new System.Drawing.Size(676,389);
        this.Controls.Add(this.label1);
         this.Controls.Add(this.button1);
         this.Controls.Add(this.textbox2);
        this.Controls.Add(this.textbox5);
        this.Controls.Add(this.textbox4);
        this.Controls.Add(this.textbox3);
        this.Controls.Add(this.textbox1);
        this.Name="Form1";
        this.Text="Form1";
        this.ResumeLayout(false);
        this.PerformLayout();
    }
    private System.Windows.Forms.Label label1;
     private System.Windows.Forms.Button button1;
     private System.Windows.Forms.TextBox textBox2;
     private System.Windows.Forms.TextBox textBox5;
     private System.Windows.Forms.TextBox textBox4;
     private System.Windows.Forms.TextBox textBox3;
    private System.Windows.Forms.TextBox textBox1;
}}
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;
using System.Data.OleDb;
public partial class Form1:Form {
    public Form1();
    InitializeComponent();}
private void button1_Click(object sender,EventArgs e) {
int a,b,c,d,m,f;
try{
a=int.parse(textBox1.Text);
b=int.parse(textBox2.Text);
c=int.parse(textBox3.Text);
d=int.parse(textBox4.Text);
f=int.parse(textBox5.Text);
if(a>100||b>100|c>100||d>100||m>100)
throw new Exception();
for=(a+b+c+d+m)/5;
if(f>80){
MessageBox.Show("the grade of the student is A");}
else{
if(f>60)
MessageBox.Show("the grade of the student is B");}
else{
if(f>45){
MessageBox.Show("the grade of the student is C");}
else{
MessageBox.Show("the grade of the student is D");
}}}
textBox1.Text="";
textBox2.Text="";
textBox3.Text="";
textBox4.Text="";
textBox5.Text="";
}
}  }  }





OUTPUT


CLICK TO DOWNLOAD

No comments:

Post a Comment