Page

Java program to find odd or even

import java.util.Scanner;

class OddOrEven
{
   public static void main(String args[])
   {
      int x;
      System.out.println("Enter an integer to check if it is odd or even ");
      Scanner in = new Scanner(System.in);
      x = in.nextInt();

      if ( x % 2 == 0 )
         System.out.println("You entered an even number.");
      else
         System.out.println("You entered an odd number.");
   }
}


OUTPUT



Java program to print multiplication table

import java.util.Scanner;

class MultiplicationTable
{
   public static void main(String args[])
   {
      int n, c;
      System.out.println("Enter an integer to print it's multiplication table");
      Scanner in = new Scanner(System.in);
      n = in.nextInt();
      System.out.println("Multiplication table of "+n+" is :-");

      for ( c = 1 ; c <= 10 ; c++ )
         System.out.println(n+"*"+c+" = "+(n*c));
   }
}


OUTPUT


Code For Print integers In JAVA

class Integers {
  public static void main(String[] arguments) {
    int c; //declaring a variable

  /* Using for loop to repeat instruction execution */

    for (c = 1; c <= 10; c++) {
      System.out.println(c);
    }
  }
}


OUTPUT



Display message on computer screen in JAVA

class First {
  public static void main(String[] arguments) {
    System.out.println("Let's do something using Java technology.");
  }
}


OUTPUT



Start or Stop IIS Service in C#,using Asp.net

If you want to start or stop IIS service in c#, vb.net using asp.net we need to write the code like as shown below

protected void btnClick_Click(object sender, EventArgs e)
{
ServiceController controller = new ServiceController("W3SVC");
if (controller.Status == ServiceControllerStatus.Running)
controller.Stop();
else if (controller.Status == ServiceControllerStatus.Stopped)
controller.Start();
else
controller.Stop();

}


If you want to see it in complete example open your Default.aspx page and write the code like as shown below

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Start or Stop IIS service in Asp.net</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btnClick" runat="server" Text="Check Status"
onclick="btnClick_Click" />
</div>
</form>
</body>

</html>


Now we need to add System.ServiceProcess reference to our application for that right click on your application à select Add Reference à select System.ServiceProcess like as shown below





Now write the following code in code behind to check the status of IIS manager


using System;
using System.ServiceProcess;

 public partial class Default : System.Web.UI.Page
    {
       protected void Page_Load(object sender, EventArgs e)
        {
        }
     protected void btnClick_Click(object sender, EventArgs e)
      {
       ServiceController controller = new ServiceController("W3SVC");
       if (controller.Status == ServiceControllerStatus.Running)
       controller.Stop();
       else if (controller.Status == ServiceControllerStatus.Stopped)
       controller.Start();
     else
         controller.Stop();
       }
}