Showing posts with label java code. Show all posts
Showing posts with label java code. Show all posts

Sunday, November 2, 2014

, , ,

Program to add two numbers using command line argument 2

add



Code Box 
---------------------------------

/*Program to add two numbers using command line argument 2 */

class add
{
public static void main(String x[])
{
int a,b,c;

System.out.print("\nzeroth argument :"+x[0]);
a=Integer.parseInt(x[0]);
//zeroth argument in a
System.out.print("\nvalue of a= "+x[0]);


System.out.print("\nfirst argument :"+x[1]);
b=Integer.parseInt(x[1]);
//first argument in b
System.out.print("\nvalue of b= "+x[1]);

c=a+b;

System.out.print("\nSum of a+b= "+c);

}
}

Publisher: Brijmohan Lal Sahu - 3:10 AM

Sunday, September 22, 2013

, , , , , , ,

Simple Function in java without return type and without arguments


Code Box

Download Link:
Publisher: Brijmohan Lal Sahu - 3:51 PM
, , , , ,

Program for Lower Case character to Upper Case character converter


Code Box
------------------------

/* program to Convert Lower Character to upper Character */

class lotoup
{
public static void main(String a[])
{

int i;
char c;

c=a[0].charAt(0);
i=c;

if(i>=97&&i<=122)
{
System.out.println("Enterd Character is :"+c);
i=i-32;
c=(char)i;

System.out.println(" Upper  Character is:"+c);
}
else
{
System.out.println("pleas enter a correct case Character");

}
}
}


Publisher: Brijmohan Lal Sahu - 3:10 PM

Wednesday, September 18, 2013

, , , , ,

Java Program to print hello your name

It's really exciting for new learner to write her/his own name in new language..
Same thing happen when you learn java and write a program that prints a beautiful line saying hello to your name..

Below code in Code Box takes your name as argument and print hello with your name.
Try it on your computer and try to modify the program by adding some more information about you.

Code Box
//A program to print hello "your_name"

class name
{
public static void main(String a[])
{
String yname;
yname=a[0];

System.out.println("hello "+yname);
}
}


If you want to make it more better do your own experiments!!
Don't limit your self & find some more programs to do...

Just for your  hint!!
Code Box 1
//A program to print hello "your_name" & "city"

class name
{
public static void main(String a[])
{
String yname,city;
yname=a[0];
city=a[1];

System.out.println("hello "+yname);

System.out.println("you are from "+city+", nice to meet you!!");

}
}



Publisher: Brijmohan Lal Sahu - 9:39 AM
, , , , , , , , ,

ASCII to CHARACTER


Code Box

Download Link:
Publisher: Brijmohan Lal Sahu - 9:37 AM
, , , , , , , ,

Program to convert characters in to ASCII values

It's very common program to convert entered characters into their ASCII values.
ASCII means American Standard Code For Information Interchange a special numerical values assigned to every type of visible & non-visible characters of computer.
You can find a complete table of ASCII values here..
ASCII Table


And More details about ASCII here!!

This program Converts any Character into its equivalent ASCII value..

Code Box
// program to print ASCII value of any character enter by user

class ascii
{
public static void main(String a[])
{

int i;
char c;

c=a[0].charAt(0); //marker 1
i=c;


System.out.println("Enterd character is:"+a[0]);
System.out.println("    ASCII value is :"+i);

}

}



//marker 1 : charAt() java built in function that capture a character from a string 
               Syntax: char variable=string.charAt(position);
              Where  #string is any string from which you want to to capture the character
                       # position a numerical value or position of character in string

Note: java takes everything as String. In above program a[0] means 0th argument and charAt(0) means its first character always.


To run this program in Command Prompt :

C:\User>javac ascii.java
C:\User>java ascii h


Out Put: 
Entered character is: h
ASCII value is : 104


Try it!!

If you have any query than feel free to write me. Your are also welcome for any advice & suggestions
make learning more better..
Publisher: Brijmohan Lal Sahu - 9:34 AM
, , , , , , ,

Learning Java programming....

All most every running device online or offline uses java one of the most demanding programming language. In all fields networking, software interface, application design, animation, security and operating systems.

Java if fully object oriented programming language provide an extraordinary powerful environment to developers & designers to convert idea into codes.

May be you don't know about java, But I am sure you know about Android another most popular word in market and Android is build in java.
And this is a Big reason why you need to know about java.

Android comes with a huge opportunity for those programmer & designer who know java to develop android applications, games & a lot more.  

Learning java is really simple & very interesting too. I have a good collection of java programs in very simple programming complexity & if you want to learn, than start from here..
I bet you after you finish basics of java android becomes much & more simple & easy for you.


Let's start with most basic program called say hello to java..


Code Box
//Program to print hello in java

class hello
{
public static void main(String a[])
{
System.out.println("hello to JAVA");
}
}

Publisher: Brijmohan Lal Sahu - 8:55 AM