1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | package com.java; import java.util.Scanner; public class Palindrom { public static void main(String args[]) { String original, reverse=""; Scanner in = new Scanner(System.in); System.out.println("Enter a string to check if it is a palindrome : "); original = in.nextLine(); int length = original.length(); for ( int i = length - 1 ; i >= 0 ; i-- ) reverse = reverse + original.charAt(i); if (original.equals(reverse)) System.out.println("Entered string is a palindrome."); else System.out.println("Entered string is not a palindrome."); } } /*Output: Enter a string to check if it is a palindrome : madam Entered string is a palindrome. */ |
It's all about Java development. A place mainly for java programmers.
Saturday, 10 March 2012
Palindrome program
Swap Numbers without using third variable
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | package com.kota.java; public class SwapNumbers { public static void main(String[] args) { int num1 = 10; int num2 = 20; System.out.println("Before Swapping"); System.out.println("Value of num1 is :" + num1); System.out.println("Value of num2 is :" +num2); //add both the numbers and assign it to first num1 = num1 + num2; num2 = num1 - num2; num1 = num1 - num2; System.out.println("Before Swapping"); System.out.println("Value of num1 is :" + num1); System.out.println("Value of num2 is :" +num2); } } /* Output : Before Swapping Value of num1 is :10 Value of num2 is :20 After Swapping Value of num1 is :20 Value of num2 is :10*/ |
Swap Numbers using third variable
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | package com.kota.java; public class SwapNumbers { public static void main(String[] args) { int num1 = 10; int num2 = 20; System.out.println("Before Swapping"); System.out.println("Value of num1 is :" + num1); System.out.println("Value of num2 is :" +num2); //swap the value swap(num1, num2); } private static void swap(int num1, int num2) { int temp = num1; num1 = num2; num2 = temp; System.out.println("After Swapping"); System.out.println("Value of num1 is :" + num1); System.out.println("Value of num2 is :" +num2); } } /* Output : Before Swapping Value of num1 is :10 Value of num2 is :20 After Swapping Value of num1 is :20 Value of num2 is :10*/ |
Program to generate Prime numbers.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | package com.kota.java; import java.io.BufferedReader; import java.io.InputStreamReader; public class PrimeNumber { public static void main(String[] args) throws Exception{ int i; BufferedReader bf = new BufferedReader( new InputStreamReader(System.in)); System.out.println("Enter number:"); int num = Integer.parseInt(bf.readLine()); System.out.println("Prime number: "); for (i=1; i < num; i++ ){ int j; for (j=2; j<i; j++){ int n = i%j; if (n==0){ break; } } if(i == j){ System.out.print(" "+i); } } } } /* * 0utput : * -------- * Enter number:100 Prime number: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 * */ |
Wednesday, 15 February 2012
(Freshers) Employee Referral : B.Sc / BCA : 2011 / 2012 Passout @ Hyderabad
Note: This is NOT a direct Walk-In. You need to apply through Employee Referral & Only shortlisted candidates will be called for test/interview.
Note: The job openings are through Employee Referral only. You cannot apply directly.
Note: B.Sc / BCA : 2011 / 2012 Passout can only apply. Other qualifications are NOT eligible to apply.
Note: Last Date to Apply - 16th February 2012
Note: The job openings are through Employee Referral only. You cannot apply directly.
Note: B.Sc / BCA : 2011 / 2012 Passout can only apply. Other qualifications are NOT eligible to apply.
Note: Last Date to Apply - 16th February 2012
Tuesday, 17 January 2012
WIPRO - Off-campus Hiring event scheduled on 28th January 2011, across locations in India
Wipro's reputation as a pioneering and innovative company in the global technology landscape makes it a determined choice for the best of talented engineers.
Please refer Engineering Graduates of 2011 for an Off-campus Hiring event scheduled on 28th January 2011, across locations in India.
Eligibility:
· B.E / B.Tech / MCA Candidates who graduated in the year 2011 only
· Candidates from Computer Science or Information Science/Technology only
· Candidates should have 50% in 10th, 12th & 60% aggregate in their graduation.
· For MCA candidates, 60% aggregate in graduation and post-graduation
Important: Last date for referring online in WipLinks is 19th Jan 2012
Saturday, 14 January 2012
Subscribe to:
Posts (Atom)