Tuesday, March 31, 2020

എങ്ങനെ Swapping ചെയുന്നത്?


Swapping  
ഒരു പ്രക്രിയ പ്രധാന മെമ്മറിയിൽ നിന്ന് ഒരു ബാക്കിംഗ് സ്റ്റോറിലേക്ക് താൽക്കാലികമായി നീക്കി തുടർന്നുള്ള നിർവ്വഹണത്തിനായി മെമ്മറിയിലേക്ക് തിരികെ കൊണ്ടുവരുന്ന ഒരു സംവിധാനമാണ്.

Example 

#include<iostream.h>
#include<conio.h>
void main()
{
//രണ്ടു variable declare ചെയ്ത് അതിൽ value store ചെയ്തിരിക്കുന്നു. 

int a=44 ,b= 88  ;

cout<<" \n Before Swapping two number:" <<endl;
cout<<" a ="<<a<<"\n"<<" b ="<<b;

// Swapping തുടങ്ങുന്നത് 

//c എന്ന  variable declare ചെയ്യുക , എന്നിട്ട്, c  variable ലെക്ക് a variable value assign ചെയ്യുക. 

int c=a;

 // a  variable ലെക്ക് b variable value assign ചെയ്യുക. 
a= b;

 // b variable ലെക്ക് c variable value assign ചെയ്യുക. 
 a=c;


cout<<" \n After Swapping two number:" <<endl;
cout<<" a ="<<a<<"\n"<<" b ="<<b;

getch()
}






Result:

Sunday, February 23, 2020

Java Menu Driven Program

Menu-driven program A program that obtains input from a user by displaying a list of options – the menu – from which the user indicates his/her choice.


import java.util.Scanner;
class MenuDrivenExample
{
public static void main(String []args)
{
int a,b,c;
Scanner s=new Scanner(System.in);
System.out.println("   Enter any two number :"  );
a=s.nextInt();
b=s.nextInt();
do
{
System.out.println("  Choose any operation given below"   );
System.out.println("   1.Addition" );
System.out.println("   2.Subtraction " ) ;
System.out.println("   3.Multiplication" );
System.out.println("   4.Division  ");
c=s.nextInt();
switch(c)    {
case 1:        
 System.out.println("   Addition  :"  + (a+b));       
 break;
 case 2:        
 System.out.println("   Subtraction  :"   +(a-b));      
 break;
 case 3:      
 System.out.println("   Multiplication  :"   +(a*b));   
 break;
 case 4:      
 System.out.println("  Division  :"     +(a/b));
 break;
default: 
if (c==0)
System.out.println("   Program End, Try Again ");
else 
System.out.println("   please choose any operation : ");
break;
}}
while(c !=0);
}
}

Friday, February 14, 2020

Create Marklist in java program.

 

 Marklist in  java program.

 
import  java.util.Scanner;
public class MarkList
{
public void mList(int english,int hindi,int maths,int science,int  history,int malayalam)
{
System.out.println("English :"+english + "Hindi : "+hindi + "Maths : "+maths + "Science : "+science + "History : "+history + "Malayalam : "+malayalam);
float sum;
sum= english+ hindi+ maths+ science+  history+ malayalam;
double percentage=sum/6;
System.out.println("percentage :="+percentage+"%");
}
public static void main(String[] args)
{
MarkList ml=new MarkList();
Scanner sc=new Scanner(System.in);
System.out.println("English:");
int english=sc.nextInt();
System.out.println("Hindi:");
int hindi=sc.nextInt();
System.out.println("Maths:");
int maths=sc.nextInt();
System.out.println("Science:");
int science=sc.nextInt();
System.out.println("History:");
int  history=sc.nextInt();
System.out.println("Malayalam:");
int malayalam=sc.nextInt();
sc.close();
ml.mList(english, hindi , maths , science , history ,malayalam);
}
}

Java program enter Student Details and find total of marks.

import java.util.Scanner;
public class StudentDetails
{
    public static void main(String[] args)
        {
        Scanner sc=new Scanner(System.in);
        System.out.print("Enter your Name:");
        String name=sc.next();
        System.out.print("Enter your Register no:");
        int register =sc.nextInt();
        System.out.print("Enter your Course");
        String course=sc.next();
        System.out.print("Enter your Place");
        String place=sc.next();
        System.out.print("Enter your Class");
        String cls=sc.next();
        System.out.print("Enter your  marks");
        int mark1=sc.nextInt ();
        int mark2=sc.nextInt ();
        int mark3=sc.nextInt ();
       int marks=mark1+mark2+mark3;
        sc.close ();
        System.out.println("\nName :"+name+"\nRegister no :"+register+"\nCourse :"+course+"\nPlace :"+place+"\nClass :"+cls+"\nTotal Marks :"+marks);
   
    }
}

Enter employee salary and find monthly and year salary.

import java.util.Scanner;
public class EmployeeSalary
{
            public void emplo(int a,int b)
        {
            System.out.println( "Monthly earning:"+a);
            System.out.println("Monthly expence:" + b);
                int c;int d;
c=a-b;
d=c*12;
System.out.println("Monthly Slalary:  "+c);
System.out.println("Yearly Salary: "+d );
}
   
    public static void main(String[] args)
        {
            Scanner sc=new Scanner(System.in);
            EmployeeSalary  es=new EmployeeSalary();
            System.out.println("monthly earning:");
            int a=sc.nextInt();
            System.out.println("monthly expence:");
            int b=sc.nextInt();
            sc.close ();
            es.emplo(a, b);
        }
}

Enter Employee Details in java program.

 Employee Details in java program. 

import java.util.Scanner;
public class EmployeeDetails
{
            public void employee(String name, int id ,String address ,int salary ,String stream)
        {
            System.out.println( "Employee name:"+ name);
            System.out.println("Employee id no:" + id );
            System.out.println("Employee address:" +  address );
            System.out.println("Employee salary:" + salary );
             System.out.println("Employee stream:" + stream);
   
        }
   
    public static void main(String[] args)
        {
            Scanner sc=new Scanner(System.in);
            EmployeeDetails ed=new EmployeeDetails();
            System.out.println("Employee name:");
            String name=sc.next();
            System.out.println("Employee id no:");
            int  id=sc.nextInt();
            System.out.println("Employee address");
            String address=sc.next();
            System.out.println("Employee salary");
            int salary=sc.nextInt();
            System.out.println("Employee stream");
            String stream=sc.next();
            sc.close ();
            ed.employee(name , id , address , salary ,stream);
        }
}

BubbleSort in Java Program

 
 
Image result for Bubble Sort in java concept 
 
 

 BubbleSort in Java Program

import java.util.Scanner;
public class BubbleSort
{
    public static void main(String[] args)
        {
        int num,i,j,temp;
        Scanner input = new Scanner(System.in);
        System.out.println("Enter the number of integers to sort :");
        num=input.nextInt();

        int array[ ] =new int [num];

        System.out.println("Enter "+num+"inegers:");

        for (i=0;i<num;i++)
        array[i]=input.nextInt();

        for(i=0;i<(num-1);i++)
        {
            for(j=0;j<num-1-i;j++)
              {
                 if (array [j] >array [j+1]);
                {
                temp= array[ j ];
                array[j]=array[j+1];
                array[j+1]=temp;
                }
        }
    }
           
        System.out.println("Sorted  list of integers:");
            for(i=0;i<num;i++)
                System.out.println(array[i]);
    }
}