using System;using System.Drawing;using System.Windows.Forms;// custom delegatepublic delegate void StartDelegate();class EventDemo : Form{// custom eventpublic event StartDelegate StartEvent;public EventDemo(){Button clickMe = new Button();clickMe.Parent = this;clickMe.Text = "Click Me";clickMe.Location = new Point((ClientSize.Width - clickMe.Width) /2,(ClientSize.Height - clickMe.Height)/2);// an EventHandler delegate is assigned// to the button's Click eventclickMe.Click += new EventHandler(OnClickMeClicked);// our custom "StartDelegate" delegate is assigned// to our custom "StartEvent" event.StartEvent += new StartDelegate(OnStartEvent);// fire our custom eventStartEvent();}// this method is called when the "clickMe" button is pressedpublic void OnClickMeClicked(object sender, EventArgs ea){MessageBox.Show("You Clicked My Button!");}// this method is called when the "StartEvent" Event is firedpublic void OnStartEvent(){MessageBox.Show("I Just Started!");}static void Main(string[] args){Application.Run(new EventDemo());}}
Write a program to calculate the total expenses. Quantity and price per item are input by the user and discount of 10% is offered if the expense is more than 7000.
#include<iostream.h> #include<conio.h> void main() { int totalexp, qty, price, discount; cout<<" Enter quantity: "; cin>>qty; cout<<" Enter price: "; cin>>price; totalexp=qty*price; if (totalexp>7000) { discount=(totalexp*0.1); totalexp=totalexp-discount; } cout<<" Total Expense is Rs. "<<totalexp; getch(); }
Comments
Post a Comment