Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Saturday, July 28, 2012

CJ-7: Check whether eligible for vote

Type the programs in NOTEPAD or DOS prompt itself, for Consol Application.
Type in NETBEANS or ECLIPSE for Window Application.
Here after , I am just typing the programs only..to know more about it , refer

Introduction to JAVA 

before doing any JAVA Programs.
***********************************************************************************************
import java.io.*;
class chk
{
public static void main(String args[])
{
int age;
try
{
   DataInputStream x=new DataInputStream(System.in);
   System.out.println("Enter age :");
   age=Integer.parseInt(x.readLine());
if(age>=18)
{
System.out.println("Eligible for vote");
}
else
{
System.out.println("Not Eligible for vote");
}
}
catch(Exception e)
{
}
}
}
========================================================================= 
Output : 
Enter age :
20
Eligible for vote.




CJ-6 : Four Calculations-Floating no

Type the programs in NOTEPAD or DOS prompt itself, for Consol Application.
Type in NETBEANS or ECLIPSE for Window Application.
Here after , I am just typing the programs only..to know more about it , refer

Introduction to JAVA 

before doing any JAVA Programs.
***********************************************************************************************
import java.io.*;
class math1
{
public static void main(String args[])
{
 float a,b,result;
 try
 {
  DataInputStream x=new DataInputStream(System.in);
  System.out.println("Enter the first number :");
  a=Float.parseFloat(x.readLine());
  System.out.println("Enter the second number :");
  b=Float.parseFloat(x.readLine());
   result=a+b;
   System.out.println("Addition = "+result);
   result=a-b;
   System.out.println("Subtraction = "+result);
   result=a*b;
   System.out.println("Multiplication = "+result);
   result=a/b;
   System.out.println("Division = "+result);
 }
 catch(Exception e)
 {
 }
}
}
========================================================================= 
Output : 
Enter the first number
12.24
Enter the second number
12.28
Addition=24.52
Subtraction =-0.03999996
Multiplication =150.30719
Division=0.99674267

Refer Four Calculations-Floating no also.




CJ-5 : Four Calculations-Integer no

Type the programs in NOTEPAD or DOS prompt itself, for Consol Application.
Type in NETBEANS or ECLIPSE for Window Application.
Here after , I am just typing the programs only..to know more about it , refer

Introduction to JAVA 

before doing any JAVA Programs.
***********************************************************************************************
import java.io.*;
class math
{
public static void main(String args[])
{
int a,b,result;
try
{
DataInputStream x=new DataInputStream(System.in);
System.out.println("Enter the first number :");
a=Integer.parseInt(x.readLine());
System.out.println("Enter the second number :");
b=Integer.parseInt(x.readLine());
result=a+b;
System.out.println("Addition = "+result);
result=a-b;
System.out.println("Subtraction = "+result);
result=a*b;
System.out.println("Multiplication = "+result);
result=a/b;
System.out.println("Division = "+result);
}
catch(Exception e)
{
}
}
}
========================================================================= 
Output : 
Enter the first number
8
Enter the second number
4
Addition=12
Subtraction =4
Multiplication =32
Division=2


Refer Four Calculations-Floating no also.







CJ-4 : Sum(user defined values)

Type the programs in NOTEPAD or DOS prompt itself, for Consol Application.
Type in NETBEANS or ECLIPSE for Window Application.
Here after , I am just typing the programs only..to know more about it , refer

Introduction to JAVA 

before doing any JAVA Programs.
*********************************************************************************************
Refer Sum(predefined values) also.
*********************************************************************************************
import java.io.*;
class Adduser 
{
public static void main(String args[]) 
{   
     int a,b,sum;
     try
{
DataInputStream x=new DataInputStream(System.in);
System.out.println("Enter two numbers :");
a=Integer.parseInt(x.readLine());
b=Integer.parseInt(x.readLine());
sum=a+b;
System.out.println("Addition= "+sum);
}
   catch(Exception e)
   {
   }
}
}
========================================================================= 
Output : 
Enter two numbers :
30
20
Addition=50.



CJ-3 : Sum(predefined values)

Type the programs in NOTEPAD or DOS prompt itself, for Consol Application.
Type in NETBEANS or ECLIPSE for Window Application.
Here after , I am just typing the programs only..to know more about it , refer

Introduction to JAVA 

before doing any JAVA Programs.
************************************************************************************
Refer Sum(user defined values) also.
************************************************************************************
class Add 
{
public static void main(String args[]) 
{   
     int a,b,c;
     a=20;
     b=40;
     c=a+b;
     System.out.println("Addition="+c);
}
}
=========================================================================
Output : Addition=60.