Core Java

JAVA PROGRAM FOR DATE AND TIME DISPLAY

A Simple Java Program for displaying Date and Time:

// HelloDate.java. 
/** Here we have a class comment
 * We see (a) Use of import and Java standard library, (b)
 *  use of comment documentation using the openning /**
 */

import java.util.*;

/** java.util is a class in java containing several convinient methods.
  * It includes, but is not limited, to some array manipulations tools,
  * a collection framework and date and time tools.
  */
public class HelloDate {
    /** Sole entry point to application 
     */
    public static void main (String[] args) {
 System.out.println (“Hello, it’s: “);
 System.out.println(new Date());
    }
}

JAVA PROGRAM FOR MATHEMATICAL OPERATIONS

A Simple Java Program for demonstrating mathematical operations:

importjava.io.BufferedReader;
importjava.io.IOException;
importjava.io.InputStreamReader;
public class Rise {
public Rise(){};

public static void main (String[] args)
    {
System.out.println(“Hello”);
      String username = null;
      String userExit= “N”;

try {
while(userExit.equalsIgnoreCase(“N”))
                  {

BufferedReader reader= new BufferedReader(new InputStreamReader(System.in));
System.out.print(“Please enter user name : “);
username = reader.readLine();

System.out.println(“Welcome :” + username);
System.out.print(“Please enter A for Addition, S for Subtraction and M for Multiplication: “);

                  String userChoice = null;
userChoice = reader.readLine();

if(userChoice.equalsIgnoreCase(“A”))
                 {
System.out.print(“Please enter two numbers to add: “);
int a =  Integer.parseInt(reader.readLine());
int b =  Integer.parseInt(reader.readLine());
int c = a+b;
System.out.print(“The Sum is: “+c);
                 }

else if(userChoice.equalsIgnoreCase(“S”))
                 {
System.out.print(“Please enter two numbers to subtract: “);
int a = Integer.parseInt(reader.readLine());
int b = Integer.parseInt(reader.readLine());
int c = a-b;
System.out.print(“The Difference is: “+c);
                  }

else if(userChoice.equalsIgnoreCase(“M”))
                  {
System.out.print(“Please enter two numbers to multiply: “);
int a = Integer.parseInt(reader.readLine());
int b = Integer.parseInt(reader.readLine());
int c = a*b;
System.out.print(“The Product is : “+c);
                   }
else
                   {
System.out.print(“Error!!! “);
                   }
System.out.print(“Do you want to continue Y/N?: “);
                    String yesNo = reader.readLine();

if (yesNo.equalsIgnoreCase(“N”))
                    {
userExit =”Y”;
                    } 
else
                    {
userExit =”N”;
                    }
                  }

               } catch (IOException e) {
e.printStackTrace();
               }
         }
 }

JAVA PROGRAM FOR CALCULATION OF PROJECT BILL

A Simple Java Program to calculate the total bill values for different types of associates in a project.

importjava.io.BufferedReader;
importjava.io.IOException;
importjava.io.InputStreamReader;

public class PickBillRate {

publicPickBillRate(){};

public static void main (String[] args)

    {

System.out.println(“Hello”);
      String username = null;
      String userExit =”N”;

try{
while(userExit.equalsIgnoreCase(“N”))
             {

BufferedReader reader= new BufferedReader(new InputStreamReader(System.in));
System.out.print(“Please enter use name:”);
 username = reader.readLine();

System.out.println(“Welcome :” +username);
System.out.print(“Please enter Dev for Programmer, AOff for Offshore Analyst, AOn for Onsite Analyst:”);

               String userChoice =null;
userChoice = reader.readLine();
if(userChoice.equalsIgnoreCase(“Dev”))
                {
intDevrate = 1000;
System.out.print(“Please enter number of Programmers:”);
int Doff = Integer.parseInt(reader.readLine());
int Val = Devrate*Doff;
System.out.print(“The Programmer Rate is:” + Val);

                }
else if (userChoice.equalsIgnoreCase(“AOff”))
                {
intBoffrate = 1500;
System.out.print(“Please enter number of Offshore Analysts:”);
intBoff = Integer.parseInt(reader.readLine());
int Val = Boffrate*Boff;
System.out.print(“The Analyst Rate for Offshore is:”+ Val);
                }
else if (userChoice.equalsIgnoreCase(“AOn”))
                {
intBonrate = 4500;
System.out.print(“Please enter number of Onsite Analysts:”);
int Bon  = Integer.parseInt(reader.readLine());
int Val = Bonrate*Bon;
System.out.print(“The Analyst Rate for Onsite is :”+ Val);
                }
else
                {
System.out.print(“Error!!!”);
                }
System.out.print(” Do you want to continue Y/N : “);

                    String yesNo  =reader.readLine();
if (yesNo.equalsIgnoreCase(“N”))
                    {
userExit = “Y”;
                    }
else
                    {
userExit = “N”;
                    }
                }
         } catch (IOException e)

         {
e.printStackTrace();
         }
    }

}