Pages

Java Program to Find Factorial

In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example,
5! = 5  \times  4  \times  3  \times  2  \times  1 = 120.  \
The value of 0! is 1, according to the convention for an empty product


 import java.util.Scanner;
  public class Factorial {
  public static void main(String[] args) {
    int num  ,fact=1;
    System.out.println("enter number:");
    Scanner sc=new Scanner(System.in);

    num=sc.nextInt();
    if(num<0){
    System.out.println("only positive number !");
   }
   else{

    for(int i=1;i<=num;i++)
    {
     fact=fact*i;
    }
    System.out.println("the factorial of "+num + " is " +fact);
    }
   }
 }

Output:
=======

 enter number: 3
 the factorial of 3 is 6

Reading a String

The String class represents character strings. All string literals in Java programs, such as "abc" , are implemented as instances of this class.Strings are constant; their values cannot be changed after they are created. String buffers support mutable strings. Because String objects are immutable they can be shared.


Reading a String
<
import java.util.Scanner;
public class ReadString {
 public static void main(String[] args) {
  System.out.println("enter a String: ");

  Scanner sc =new Scanner(System.in);
while(true){
String s=sc.nextLine();
               s=s.toLowerCase();
if(s.indexOf("hari")!=-1){
System.out.println("Hi,hari!");
}
else{
System.out.println("Who are you?");
}
break;
}
}

}


OutPut:
Enter a String:  hari
Hi,hari!

Program to find out the Repetition of character in a String

 Repetition of character in a String

import java.util.Scanner;
public class A {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter the String : ");
String value = sc.nextLine();
//System.out.println();
System.out.print("Enter the Charcter : ");
String ch = String.valueOf((sc.next().charAt(0)));
int count=0;
for(int i=0;i<value.length();i++)
{
if((String.valueOf(value.charAt(i))).equalsIgnoreCase(ch))
{
count++;
}
}
System.out.println("The character : "+ ch +" is present "+count+" times");
}
}

Output :
Enter the String : hello
Enter the Charcter : l
The character : l is present 2 times
 


Program to find count of vowels and consonant

Program to find count of vowels and consonant


import java.util.Scanner;
public class Vowel {
public static void main(String[] args) {
System.out.println("enter a string:");
Scanner sc=new Scanner(System.in);
String v=sc.nextLine();
int len=v.length();
char[] vw={'a','e','i','o','u'};
int count=0;
for(int i = 0 ; i< len;i++)
{
for(int j = 0; j<5;j++)
{
if((String.valueOf(v.charAt(i))).equalsIgnoreCase((String.valueOf(vw[j]))))
{
count++;
}
 }
    }
System.out.println("In this String there are "+count+" vowels and "+(len-count)+" consonant.");
   }
 }

Reverse a String in java

1.//Program to write  reverse a string



public class Reverse {
public static void main(String[] args) {

String s="abcd";
String rs="";
for (int i=s.length()-1;i>=0;i--){
rs=rs+s.charAt(i);
}
System.out.println(s);
System.out.println(rs);
}
}

OutPut :

abc
cba

2. Using StringBuffer(String string) method, reverse the buffer and then converts the buffer into a String with the help of toString()


public class StringReverseExample{
   public static void main(String[] args){
      String string="abcdef";
      String reverse = new StringBuffer(string).
      reverse().toString();
      System.out.println("\nString before reverse:
      "+string);
      System.out.println("String after reverse:
      "+reverse);
   }
}

3. Another  


public class Reverse {

public String reverseString(String s){
if (s.length()<=1){
return s;
}
else 
{
char c=s.charAt(0);
return reverseString(s.substring(1))+c;
}
}
}

class StringReverse{
public static void main(String[] args){
Reverse r=new Reverse();
String s1="abcde";
System.out.println("Given String="+ (s1));
System.out.println("Reverse String="+ r.reverseString(s1));
}
}

Output:

Given String=abcde
Reverse String=edcba

4. String Input from Keyword 


import java.util.Scanner;
public class A {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter the String : ");
String value=sc.nextLine();
int len = value.length();
char[] ch = new char[len];
for(int i = 0;i<len;i++)
{
ch[i]= value.charAt(len-1-i);
}
String result = new String (ch);
System.out.println(result);
}
}


How to fix the minor cracks in your building


Issued by Engineers & Architects after earthquake group
(http://on.fb.me/1zJqpHC)

Plaster Cracks

Below 10 mm.

Material : Doctor Fixit Crack ‘X’ Paste
Procedure :

  • 1. First cut the crack with ‘V’ Shape
  • 2. Clean the crack area.
  • 3. Moisture the crack area.
  • 4. Apply the crack paste by running hand.
  • 5. Leave it by

How to Get Started With Photoshop

Learning  Adobe Photoshop is quite easy. We finds so many video tutorials in the youtube.com for all level. We can do what ever we want provided that we must know basic and some good practice .
Creative minds are always active  

Adobe Photoshop


Requirement:

  • Creative minds
  • Enthusiastic
  • Adobe Photoshop software
  • Practice 
  • Practice
  • Practice
  • Practice

how to write resume




RAVI JAIN
12/1 N S Road, P.O. Lal Bag, Delhi-110001
09876543210, ravijain@gmail.com, ravijain@yahoo.in


 Professional Qualification:

  • Passed Professional Programme from ICSI in June 2012.
  • Passed CS (Executive Programme) from ICSI in June 2010.
  • Passed CS (Foundation Programme) from ICSI in June 2009.

Top 15 Most Popular Blogs | April 2015

Reference

Here are the top 15 Most Popular Blogs as derived from our eBizMBA Rank which is a continually updated average of each website's Alexa Global Traffic Rank, and U.S. Traffic Rank from both Compete and Quantcast."*#*" Denotes an estimate for sites with limited data.

How to make money online.

When I read about making money on most sites it always seems to be a little cheesy or some type of link hacking system that is to good to be true.

Data Types in Java ( Part 2)

#.  Why do we have  8 Primitive data type?
Based on type and range of data ,primitive  types are divided into 8 types.

#.   Why do we have  4  referenced data type?
To collect same type of values of Array is given and to collect different type of values class,interface and enum are given.

JVM creates memory location based on the data type size,names that ML with the given name,and stores the assigned value in the memory location . This named memory location is technically called variable.

Example: 

class DataTypesDemo{ 
 //primitive type variable creation  

         byte b =10; int i =20; char ch ='a';

    //Array type variable creation 
       
         double[] d ={1,2,3,4,5};

    //predefined class string type variable creation 

         String str = "Hari";

       public static void main(String [] args) 
     { </br>

         //User defined class DataTypeDemo variable creation

           DataTypesDemo dd=new DataTypesDemo(); 
    }}

Data Types in Java ( Part 1)



              For the most commonly used data types, Java provides the following base types
              (also called primitive types):


                                                         boolean        a boolean value: true or false
                                              char             16-bit Unicode character
                                              byte              8-bit signed two’s complement integer
                                              short            16-bit signed two’s complement integer
                                              int                32-bit signed two’s complement integer
                                              long             64-bit signed two’s complement integer
                                             float              32-bit floating-point number (IEEE 754-1985)
                                             double          64-bit floating-point number (IEEE 754-1985)


                     A variable having one of these types simply stores a value of that type. Integer
                     constants, like 14 or 195, are of type int, unless followed immediately by an ‘L’
                     or ‘l’, in which case they are of type long. Floating-point constants, like 3.1416
                     or 6.022e23, are of type double, unless followed immediately by an ‘F’ or ‘f’, in
                     which case they are of type float. Code Fragment 1.1 demonstrates the declaration,
                     and initialization in some cases, of various base-type variables



               1 boolean flag = true;
               2 boolean verbose, debug;            // two variables declared, but not yet initialized
               3 char grade = 'A';
               4 byte b = 12;
               5 short s = 24;
               6 int i, j, k = 257;                         // three variables declared; only k initialized
               7 long l = 890L;                           // note the use of ”L” here
               8 float pi = 3.1416F;                    // note the use of ”F” here
               9 double e = 2.71828, a = 6.022e23;   // both variables are initialized

Top 10 Reasons to Major in Computing

1. Computing is part of everything we do!
Computing and computer technology are part of just about everything that touches our lives from the cars we drive, to the movies we watch, to the ways businesses and governments deal with us. Understanding different dimensions of computing is part of the necessary skill set for an educated person in the 21st century. Whether you want to be a scientist, develop the latest killer application, or just know what it really means when someone says “the computer made a mistake”, studying computing will provide you with valuable knowledge.

2. Expertise in computing enables you to solve complex, challenging problems.

Computing is a discipline that offers rewarding and challenging possibilities for a wide range of people regardless of their range of interests. Computing requires and develops capabilities in solving deep, multidimensional problems requiring imagination and sensitivity to a variety of concerns.

3. Computing enables you to make a positive difference in the world.

Computing drives innovation in the sciences (human genome project, AIDS vaccine research, environmental monitoring and protection just to mention a few), and also in engineering, business, entertainment and education. If you want to make a positive difference in the world, study computing.

4. Computing offers many types of lucrative careers.

Migrating to Android Studio

If you have been using Eclipse with ADT, be aware that Android Studio is now the official IDE for Android, so you should migrate to Android Studio to receive all the latest IDE updates.
To migrate existing Android projects, simply import them using Android Studio:
  1. In Android Studio, close any projects currently open. You should see theWelcome to Android Studio window.
  2. Click Import Non-Android Studio project.
  3. Locate the project you exported from Eclipse, expand it, select thebuild.gradle file and click OK.
  4. In the following dialog, leave Use gradle wrapper selected and click OK. (You do not need to specify the Gradle home.)

M. TECH. COMPUTER SCIENCE

(R13) COURSE STRUCTURE AND SYLLABUS


I Year I Semester


Advanced Data Structures and Algorithms 
Computer System Design 
Advanced Operating Systems 
Software Process and Project Management