Posts

Practical 9 - Create a simple Web service get a GET and POST endpoint for greetings

Create New WebSite Project in Visual Studio. Right click on the Solution explorer and Add New Item and Choose Web Service and save file. Write the following code in the file created and run it to test.   Webservice.cs using  System;   using  System.Collections.Generic;   using  System.Web;   using  System.Web.Services;   ///<summary>    /// Summary description for UtilityWebService    ///</summary>    [WebService(Namespace =  "http://tempuri.org/" )]   [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]   // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.     // [System.Web.Script.Services.ScriptService]    public   class ...

Image Upload using ASP.Net with C# (Practical 8)

Default.aspx <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title></title> </head> <body>     <form id="form1" runat="server">     <div>             <asp:FileUpload ID="FileUpload1" runat="server" />         <br />         <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />         <br />         <br />         <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>         <br />         <br />         <asp:GridView ID="GridView1" runat="server">   ...

Practical 5 - ASP.NET

Page1.aspx <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Page1.aspx.cs" Inherits="StudentInformation.Page1" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title></title> </head> <body>     <form id="form1" runat="server">     <div>             <table style="width:100%;">             <tr>                 <td>Name:</td>                 <td>                     <asp:TextBox ID="txtName" runat="server"></asp:TextBox>                 </td>             </tr>             <tr>   ...

C# Code to Convert Temperature from degree Celcius to degree Fahrenheit

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Operators_A {     class Program     {         static void Main(string[] args)         {             /*              * 1. Arithmetic Operators              *  a. + (Addition)              *  b. - (Subtraction)              *  c. / (Division)              *  d. * (Multiplication)              *  e. % (Modulus, Remainder)              *  f. ++ (Increment)              *  g. -- (Decrement)              */  ...

Operator Overloading

// Operator Overloading #include <iostream> using namespace std; class Complex { private: float real; float img; public: Complex() { real = img = 0; } Complex(float real, float img) { this->real = real; this->img = img; } // Complex add(Complex c) // { // Complex tmp; // tmp.real = this->real + c.real; // tmp.img = this->img + c.img; // return tmp; // } // Opertors which cannot be oberloaded // ::, ., .*, ?: Complex operator +(Complex c) { Complex tmp; tmp.real = this->real + c.real; tmp.img = this->img + c.img; return tmp; } Complex operator -(Complex c) { Complex tmp; tmp.real = this->real - c.real; tmp.img = this->img - c.img; return tmp; } void display() { cout << this->real << " + " << this->img << "i" << endl; } }; int main() { Complex c1(10.5, 20.5), c2(9.3, 3.5), c3; // c3 = ...

Single Level Inheritance

#include <iostream> using namespace std; /*  * Types:  * 1. Single-Level Inheritance  * 2. Multi-level  * 3. Multiple  * 4. Hybrid  */ class Shape { private:   float width;   float height; public:   Shape()   {     this->width = this->height = 0.0;   }   Shape(float width, float height)   {     this->width = width;     this->height = height;   }   float get_width()   {     return this->width;   }   float get_height()   {     return this->height;   }   float getArea()   {     return this->width * this->height;   } }; class Square : public Shape { public:   Square() { }   Square(float side) : Shape(side, side)   {   }   float getPerimeter()   {     return 2 * this->get_width() + 2 * this-...

Constructors while inheritance

#include <iostream> #include <string.h> using namespace std; class A { public:   A()   {     cout << "A's constructor" << endl;   }   A(string s)   {     cout <<  "A's " << s << endl;   } }; class B : public A { public:   B()   {     cout << "B's constructor" << endl;   }   B(string s) : A(s)   {     cout << "B's " << s << endl;   } }; class C : public B { public:   C()   {     cout << "C's constructor" << endl;   }   C(string s) : B(s)   {     cout << "C's " << s << endl;   } }; int main(int argc, char const *argv[]) {   C c("Hello");   return 0; }

HashMap Example Code

import java . util . HashMap ; import java . util . Map ; import java . util . Iterator ; import java . util . Set ; public class HashMapEx { public static void main ( String args []) { HashMap < Integer , String > hmap = new HashMap < Integer , String >(); // Adding to HashMap hmap . put ( 12 , "Kabir" ); hmap . put ( 2 , "Ravi" ); hmap . put ( 7 , "Luis" ); hmap . put ( 49 , "Peter" ); hmap . put ( 3 , "Aditya" ); // Iterate through HashMap Set set = hmap . entrySet (); Iterator iterator = set . iterator (); while ( iterator . hasNext ()) { Map . Entry mentry = ( Map . Entry ) iterator . next (); System . out . print ( "Key is: " + mentry . getKey () + " & Value is: " ); System . out . println ( mentry . getValue ()); } // Get a value...

Program to Create arraylists for Courses and Students using OOP concepts with getter and setter methods

Course.java public class Course { private String id; private String name; public Course() { } public Course(String id, String name) { this.id = id; this.name = name; } public void setId(String id) { this.id = id; } public String getId() { return this.id; } public void setName(String name) { this.name = name; } public String getName() { return this.name; } @Override public String toString() { return this.id; } } Student.java public class Student { private int rollNo; private String name; private Course course; private String address; private int phoneNumber; /** * Default Constructor */ public Student() { } /** * Overloaded Constructor */ public Student(int rollNo, String name, String address, int phoneNumber, Course course) { this.rollNo = rollNo; this.name = name; this.address = address; this.phoneNumber = phoneNumber; this.course = course; } /** * Setter for rol...

Linear Array using Pointer

#include <stdio.h> #include <stdlib.h> int main(int argc, char const *argv[]) { int *a; // Pointer int size; printf("Size of an array: "); scanf("%d", &size); // malloc()- it allocates the memory dynamically to a pointer variable a = malloc(sizeof(int) * size); printf("Enter %d elements of an array: "); for (int i = 0; i < size; i++) scanf("%d", &a[i]); // Behaving like an array printf("You've entered: "); for (int i = 0; i < size; i++) printf("%d ", a[i]); printf("\n"); return 0; }

Call by Value vs Call by Reference

/* Call by Value vs Call by Reference  */ #include <stdio.h> void swap(int x, int y) { int temp = x; x = y; y = temp; } void rswap(int *x, int *y) { int temp = *x; *x = *y; *y = temp; } int main(int argc, char const *argv[]) { int a, b; printf("a = "); scanf("%d", &a); printf("b = "); scanf("%d", &b); printf("a = %d, b = %d\n", a, b); rswap(&a, &b); // Call by reference printf("a = %d, b = %d\n", a, b); return 0; }

Inheritance

Shape.java package math.shapes; public class Shape { protected float side; public float perimeter() { return 0.f; } public float area() { return 0.f; } } Circle.java package math.shapes; public class Circle extends Shape { public Circle() { side = 0.f; } public Circle(float side) { this.side = side; } @Override public float perimeter() { return 2 * (float)Math.PI * side; } @Override public float area() { return (float)Math.PI * side * side; } } Rectangle.java package math.shapes; public class Rectangle extends Shape { private float side2; public Rectangle() { side = side2 = 0.f; } public Rectangle(float side, float side2) { this.side = side; this.side2 = side2; } @Override public float perimeter() { return 2 * (side + side2); } @Override public float area() { return side * side2; } } Square.java package math.shapes; public class Square extends Shape { public ...

Packages

Circle.java package shapes; public class Circle { private float radius; public Circle() { this.radius = 0.0f; } public Circle(float radius) { this.radius = radius; } public float getArea() { return (float)Math.PI * this.radius * this.radius; } public float getCircumference() { return 2 * (float)Math.PI * this.radius; } } TestCircle.java import shapes.Circle; public class TestCircle { public static void main(String[] args) { Circle circle1 = new Circle(5.f); Circle circle2 = new Circle(12.45f); System.out.println("Circumference of circle1 = " + circle1.getCircumference()); System.out.println("Area of circle1          = " + circle1.getArea()); System.out.println("Circumference of circle2 = " + circle2.getCircumference()); System.out.println("Area of circle2          = " + circle2.getArea()); } }

Complex Number Program in Java

/**  * Program to create a class for Complex Number.  * The class should contain real and imginary properties along  * add, subtract and product on complex numbers.  *  * Test your class on two complex numbers  */ class Complex { private float real; private float img; /** * Default constructor */ Complex() { this.real = this.img = .0f; } /** * Parameterized conctructor 1 */ Complex(float val) { this.real = this.img = val; } /** * Parameterized conctructor 2 */ Complex(float real, float img) { this.real = real; this.img = img; } /** * Addition */ public Complex add(Complex c) { return new Complex(this.real + c.real, this.img + c.img); } /** * Subtraction */ public Complex subtract(Complex c) { return new Complex(this.real - c.real, this.img - c.img); } /** * Multiplication * a + bi X c + di = (ac - bd) + (ad + cb)i */ public Complex product(Complex c...

Project Work-I Guidelines and Marks Distribution

Distribution of Internal Marks - Project Work-I (BSBC 506) S. No. Evaluation Criteria for Awarding Marks Max. Marks 1 File End Term Evaluation 1)   Problem Formulation a)   Drawbacks of Current System  b)   Need 2)   Objectives 3)   Feasibility Study 4)   Requirement Analysis & System Design a)   Data Flow Diagram        5 b)   Database Design          5 i.   Tables Structure ii.   ERD  5 10 5 10 2 Attendance Below < 75%                      0 [75-80)%             ...