Blogger Tips and TricksLatest Tips And TricksBlogger Tricks

Caesar Cipher implementation in java

PROGRAM:


import java.util.Scanner;

public class ceasercipher
{
    public static final String ALPHABET = "abcdefghijklmnopqrstuvwxyz";

    public static String encrypt(String plainText, int shiftKey)
    {
        plainText = plainText.toLowerCase();
        String cipherText = "";
        for (int i = 0; i < plainText.length(); i++)
        {
            int charPosition = ALPHABET.indexOf(plainText.charAt(i));
            int keyVal = (shiftKey + charPosition) % 26;
            char replaceVal = ALPHABET.charAt(keyVal);
            cipherText += replaceVal;
        }
        return cipherText;
    }

    public static String decrypt(String cipherText, int shiftKey)
    {
        cipherText = cipherText.toLowerCase();
        String plainText = "";
        for (int i = 0; i < cipherText.length(); i++)
        {
            int charPosition = ALPHABET.indexOf(cipherText.charAt(i));
            int keyVal = (charPosition - shiftKey) % 26;
            if (keyVal < 0)
            {
                keyVal = ALPHABET.length() + keyVal;
            }
            char replaceVal = ALPHABET.charAt(keyVal);
            plainText += replaceVal;
        }
        return plainText;
    }

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter the String for Encryption: ");
        String message = new String();
        message = sc.next();
        System.out.println("Encryption message=  "+encrypt(message, 3));
        System.out.println("Decryption message=  "+decrypt(encrypt(message, 3), 3));
        sc.close();
    }
}

OUTPUT:

CREATE A SIMPLE NAVIGATION DRAWER ACTIVITY IN ANDROID STUDIO WITHOUT ANY CODING

                              Navigation drawer is similer to menu.It is an alteration of menu in old GUI environment.If you want to upgrade your software to latest GUI features then go for navigation drawer.Now a days lot of software uses these navigation drawer.Here you can learn how to create a navigation drawer without any coding.The Screen shot of navigation drawer is shown below.



                         
1)Open new project in android studio
2)Select the version of android

3)Now select Navigation Drawer Activity as shown in below

4)Then click finish

 5)Navigation drawer activity is created as shown in below

MOBILE APPLICATION DEVELOPMENT LAB(CS6611 and IT6611)

Lab manual features
*A complete Lab Manual with pdf,source code,Procedure,download project and download android apk file for all experiment.
*Step by step procedure to install and execute all the programs.
*Anna University Latest Sylabus.Common to CSE and IT department
*Easy to execute all the experiment simply download the project.
*Have a android executable(.apk) file.Download and Run in your android device.
*Step by step procedure is available with the manual.So that  easily Run the experiment without the help of other.

A complete Lab Manual with source code for all experiment.

One day  Workshop:
                                Workshop on Mobile application development  is available for colleges.Content for the workshop are as follows
                                *Recent trends in mobile application development 
                                *Introduction about mobile application development environment(Android).
                                *Life cycle of android .Working nature of android software.
                                *Step by step installation for android software.
                                *Execution of  all lab experiments.
            Contact:8344790950

LabManual cost details
                     LAB MANUAL DVD(Rs 1000)
                                              The labmanual with dvd it includes all experiment in pdf,software and installation procedure.The labmanul cost RS1000.The dvd will be reach you with in one or two days.
                    LAB MANUAL SOFT COPY(Rs 700)
                                              The softcopy of lab manual is availabe via email.It includes all experiment in pdf,installation procedure.The labmanual cost RS700.The email will reach you shortly after payment.

Payment method:
                                              The payment has  be made to the following bank account.After payment contact as we will send our lab manual.

contact details:
CELL:8344790950
EMAIL:hitechguil@gmail.com 

Bank Account Details:

BANK NAME :STATE BANK OF INDIA
ACCOUNT NO:20222847933
ACCOUNT HOLDER NAME:P GUILBERT RAJ
IFSC CODE:SBIN0010501



Lab manual screen shot:
1.Gui component font and color
2.Layout manager:

3.Calculator:

4.Basic graphical pimitives:

5.Database application:

6.Rss Feed:

7.Multithreading Application:

8.GPS LOCATION:

9.Sdcard data storage:

10.Alert application :

11.Alarm Clock:


Lab manual in android app:



Lab manual feedback:



Implement an application that creates an alert upon receiving a message in android

1)Open eclipse or android studio and select new android project
2)Give project name and select next
3) Choose the android version.Choose the lowest android version(Android 2.2) and select next
4) Enter the package name.package name must be two word seprated by comma and click finish
5)Go to package explorer in the left hand side.select our project.
6)Go to res folder and select layout.Double click the main.xml file.Add the code below
  <ScrollView  xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:scrollbars="vertical" >
<TableLayout         
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:shrinkColumns="*"  android:stretchColumns="*" android:background="#000000">
                 
                        <TableRow
                            android:layout_height="wrap_content"
                            android:layout_width="match_parent"
                            android:gravity="center_horizontal">
                           <TextView
      android:id="@+id/Title"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_margin="5px"
      android:focusable="false"
      android:focusableInTouchMode="false"
      android:gravity="center_vertical|center_horizontal"
      android:text="QUIZ"
      android:textSize="25sp"
      android:textStyle="bold" />
                           <View
                android:layout_height="2px"
                android:layout_marginTop="5dip"
                android:layout_marginBottom="5dip"
                android:background="#DDFFDD"/>
                       </TableRow>
                        <TableRow
                            android:layout_height="wrap_content"
                            android:layout_width="match_parent"
                            android:gravity="center_horizontal">
                            <TextView
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:textSize="18sp" android:text="1.CAPTIAL OF INDIA"
android:layout_span="4"
                                android:padding="18dip"
                                android:textColor="#ffffff"/>
                       </TableRow>
                  
                        <TableRow
                            android:id="@+id/tableRow1"
                            android:layout_height="wrap_content"
                            android:layout_width="match_parent">
         <RadioGroup
            android:id="@+id/answer1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0.4" >
            <RadioButton
                android:id="@+id/answer1A"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textColor="#ffffff"
                android:text="CHENNAI" />
            <RadioButton
                android:id="@+id/answer1B"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textColor="#ffffff"
                android:text="NEW DELHI" />
            <RadioButton
                android:id="@+id/answer1C"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textColor="#ffffff"
                android:text="MUMBAI" />
             <RadioButton
                android:id="@+id/answer1D"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textColor="#ffffff"
                android:text="HYDERBAD" />
        </RadioGroup>
                        </TableRow>
                      <TableRow
                            android:layout_height="wrap_content"
                            android:layout_width="match_parent"
                            android:gravity="center_horizontal">
                            <TextView
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:textSize="18sp"
                                android:text="2. CAPTIAL OF RUSSIA?"
                                android:layout_span="4"
                                  android:padding="18dip"
                                android:textColor="#ffffff"/>
                       </TableRow>
                     
                        <TableRow
                            android:id="@+id/tableRow2"
                            android:layout_height="wrap_content"
                            android:layout_width="match_parent">
                            <RadioGroup
            android:id="@+id/answer2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0.4" >
            <RadioButton
                android:id="@+id/answer2A"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textColor="#ffffff"
                android:text="WARSAW    " />
            <RadioButton
                android:id="@+id/answer2B"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textColor="#ffffff"
                android:text="BERLIN" />
            <RadioButton
                android:id="@+id/answer2C"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textColor="#ffffff"
                android:text="MASCOW    " />
             <RadioButton
                android:id="@+id/answer2D"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textColor="#ffffff"
                android:text="CANEBRA    " />
        </RadioGroup>
                        </TableRow>
                         <TableRow
                            android:layout_height="wrap_content"
                            android:layout_width="match_parent"
                            android:gravity="center_horizontal">
                            <Button
                                android:id="@+id/submit"
                                android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                  android:gravity="center"
                                    android:text="Submit"
                                    />
                       </TableRow>                                                                       
      </TableLayout>      
</ScrollView>

7) Now select mainactivity.java file and type the following code.In my coding maniactivity name is Alert1Activity .
package alert1.quiz;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RadioGroup;
import android.widget.Toast;
import android.view.View.OnClickListener;
import android.widget.RadioGroup.OnCheckedChangeListener;
public class Alert1Activity extends Activity {
    private Button btnSubmitQuiz;
    int score,ans1,ans2;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        RadioGroup b1=(RadioGroup)findViewById(R.id.answer1);
        b1.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                // TODO Auto-generated method stub
                switch(checkedId) {
                    case R.id.answer1A:
                                                      ans1 =1;
                    break;
                    case R.id.answer1B:
                                                      ans1 =2;                  
                    break;
                    case R.id.answer1C:
                                                      ans1 =3;
                    break;
                    case R.id.answer1D:
                                                      ans1=4;
                    break;
                }
            }
        });
         RadioGroup b2=(RadioGroup)findViewById(R.id.answer2);
         b2.setOnCheckedChangeListener(new OnCheckedChangeListener() {
             public void onCheckedChanged(RadioGroup group, int checkedId) {
                 // TODO Auto-generated method stub
                 switch(checkedId) {
                     case R.id.answer2A:
                                                       ans2 =1;
                     break;
                     case R.id.answer2B:
                                                       ans2 =2;
                   
                     break;
                     case R.id.answer2C:
                                                       ans2 =3;
                     break;
                     case R.id.answer2D:
                                                       ans2=4;
                     break;
                 }
             }
         });
         btnSubmitQuiz = (Button) findViewById(R.id.submit);
         btnSubmitQuiz.setOnClickListener(new OnClickListener() {
             public void onClick(View v) {
                 AlertDialog.Builder alertDialog = new AlertDialog.Builder(Alert1Activity.this);
                  // Setting Dialog Title
                  alertDialog.setTitle("SHOW RESULT");
                  // Setting Dialog Message
                  alertDialog.setMessage("Are you sure you want SUBMIT this?");
                  // Setting Icon to Dialog
                 // alertDialog.setIcon(R.drawable.tick);
                  // Setting Positive "Yes" Button
                  alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog,int which) {
                          score =0;
                           // TODO Auto-generated method stub
                           if(ans1 == 2)
                                                             score++;
                           if(ans2 == 3)
                                                             score++;                                                                               
                           Toast.makeText(Alert1Activity.this, "Your score is:"+score+" out of 2.", Toast.LENGTH_LONG).show();
                         
                      }
                  });
                  // Setting Negative "NO" Button
                  alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int which) {
                      // Write your code here to invoke NO event
                      Toast.makeText(getApplicationContext(), "You clicked  NO.CHECK YOUR ANSWER", Toast.LENGTH_SHORT).show();
                      dialog.cancel();
                      }
                  });
                  // Showing Alert Message
                  alertDialog.show();
             }
         });
       
    }
}

8)Now go to main.xml and right click .select run as option and select run configuration
9) Android output is present in the android emulator as shown in below.







  
  
  
      

Flag Counter