MY mENU


Wednesday 23 January 2013

Why OOPs?

  • OOPs stands for “Object Orient Programming System”. It’s a technique not technology.
  • It means, it does not provide any syntaxes or API’s, instead it provides suggessitions to design and develop objects in programming language.
  • This technique is introduced to represent real world object in programming languages, the objects such as person, Animal, Shape, Vehicle, etx… and further to achieve security and to communicate with other programming languages, such as C,C++,.NET,PHP,HTML,JAVA etc… with proper connectors.
  • All living and non-living things are considered as object.
  •  If we developed project according to real world object behavior we will get many advantages.
Definition of OOPs:
  • OOP is an approach that provides a way of modularizing a program by creating partitioned memory area for both data and methods that can be used as template for creating copies of such modules on demand.
  • Unlike procedural programming, here in the OOP programming model, programs are organized around objects and data rather than actions and logic.
Building blocks of OOP: The building blocks of OOP are
  • Class
  • Object
  • Every java program must start with a class, because using class only we can represent real world objects like person, Bike, Animal.

A MobileNumber is a VIP number if it satisfy the following conditions.


  1. The operator should be Vodafone.
  2. Atleast one 0 (Zero) should be exist in mobile number.
  3. The number should not end with 8.
  4. The single digit sum of all the digits in the number should be equal to 9. For example if the number is 9876543210, the sum is 9+8+7+...+1+0 = 45. Sum of 4+5 = 9.
Write a method: 
private boolean isVIPMobileNumber(String mobileNum, String operator)
mobileNum     phone number
operator

  
mobile operator as bsnl, Vodafone

import java.io.*;
import java.lang.*;
class Phno
{
String mobileNum;
String operator;
int count=0;
long sum=0;
long total_value=0;
 long value;
 long rem;
 long rem1;

private boolean isVIPMobileNumber(String mobileNum, String operator)
{
   this.mobileNum=mobileNum;
   this.operator=operator; 
  

   int len=mobileNum.length();
if(operator!="vadafone")
{
System.out.println("network is not vadafone");
    }

//System.out.println(len);
for(int i=0;i
{
   if(mobileNum.charAt(i)=='0')
{
count=count+1;
}
}
if(count>0)
{
}
else
{
System.out.println("at least one zero not avaliablee");
}

if(mobileNum.charAt(len-1)=='8'){
System.out.println("mobile number should not end with 8");
  }
value=Long.parseLong(mobileNum);

while(value!=0)
{
rem=value%10;
value=value/10;
sum=sum+rem;
}
//System.out.println(sum);
while(sum!=0)
{
    rem1=sum%10;
sum=sum/10;
total_value=total_value+rem1;
        }
if(total_value!=9)
{
System.out.println("sum of individual no's not equal to 9");
}
//System.out.println(total_value);
  
 System.out.println("VIP number");
 
return true;


}

public static void main(String[] args) 
{
String mno="9885603834";
String network="vadafone";
Phno pn=new Phno();
pn.isVIPMobileNumber(mno,network);

}
}