Join
Blogs
Questions
Videos
Tags
Members
Search
 
 
Create your own blog, earn points and get popular!

Write a program to check whether number is palindrome or not

  1. /*
  2.  * Write a program to check whether number is palindrome or not. Number should
  3.  * be read from console. Number is considered to be palindrome if number
  4.  * and it's reversed number are same.
  5.  */
  6.  
  7. import java.io.BufferedReader;
  8. import java.io.IOException;
  9. import java.io.InputStreamReader;
  10.  
  11. public class PalindromeCheck {
  12.  public static void main(String args[]){
  13.  
  14.   System.out.println("Enter number");
  15.  
  16.   try{
  17.    
  18.    //read the number from console
  19.    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  20.    int n = Integer.parseInt(br.readLine());
  21.    
  22.    //first, we will reverse the number
  23.    int number = n;
  24.    int reversedNumber = 0;
  25.    int t =0 ;
  26.    
  27.    while(number > 0){
  28.     t = number % 10;
  29.     number = number / 10;
  30.     reversedNumber = reversedNumber * 10 + t;
  31.    }
  32.    
  33.    System.out.println("Reversed number is " + reversedNumber);
  34.    
  35.    if(n == reversedNumber)
  36.     System.out.println("Number is palindrome");
  37.    else
  38.     System.out.println("Number is not palindrome");
  39.    
  40.   }catch(NumberFormatException nef){
  41.    System.out.println("Invalid number.");
  42.   }catch(IOException ioe){
  43.    System.out.println("IO error" + ioe);
  44.   }
  45.  
  46.  }
  47. }
Your rating: None Average: 2.3 (3 votes)
Share this
Anonymous's picture

Control Your High Blood

Control Your High Blood Pressure Your success in controlling your high blood pressure is ensured by keeping a record of your pulse rates, weight loss or even the waist line. Tracking the progress involves monitoring as to what the heart is doing. Hence, one way of assessing the improvement of high blood pressure is via the pulse rates. To determine high blood pressure, pulse rates can be taken from any parts of the body with the wrist as the most preferred. All that is needed is a watch or clock with a second hand. Never use a stopwatch. Initially get the pulse by placing the elbow as high as the heart on a table. This can be improved later on without the table, by holding the arm up in the air. This can be done any time during a typical day, after exercise or when you feel like taking your pulse rate. Place the left hand to the right wrist, if you are right-handed and vice versa, using two or three fingers with the palm positioned upwards. Try to get a steady beat for a full minute. As soon as you have acquainted yourself to the beat, the full minute number of beats can be reduced to number of beats per ten seconds and multiply it by six to get the pulse rate per minute. The peripheral pressure, the transporting of blood to the muscles and the skin by the arterioles and veins, as well as the speed by which the heart pumps out blood, are all responsible in the number of beats per minute Hence, a lower pulse rate is like having a lower blood pressure. Generally, the average pulse barneys new york christian louboutin sale rate is 70 beats per minute. The pulse rate is affected by many factors, like eating, drinking, exercise, anxiety and tension. If one is consistent in getting the pulse rate at the same time each day, this can be used as a basis in setting up a basis for lowering the high blood pressure, taking into consideration the factors mentioned. In most cases, the resting pulse rate can be reduced by an exercise program, attaining an ideal weight and improved diet. Always start on a slow exercise with proper doctor consultation. Aside from exercise, meditation or mental conditioning can reduce pulse rate and blood pressure. There are many ways to get the blood pressure nowadays. There are the coin-operated machines in stores, battery-operated gadgets or the conventional type known as sphygmomanometer. To get the blood pressure using the sphygmomanometer, wrap the cuff or band authentic discount christian louboutin shoes around the arm to stop the flow of blood. Place a stethoscope to an artery below the band then slowly release the band. When the blood begins to flow, the systolic pressure or high number comes through. The beats will stop to pave the way for the diastolic pressure or low number and the sound becomes steady. To operate, the band is pumped then pressure is released from a mercury sensing device. This is commonly seen in most doctor's office. In like manner, there are already new electronic devices that can sense sensitive and objective sounds, hence, the stethoscope is no longer needed. Controlling your high blood pressure by monitoring your pulse rates in a diary will help monitor the wear and tear the body is receiving. As such, proper control in weight and intakes of sugar and cholesterol rich foods should be avoided.

Post new comment