0

`

import java.io.*;
class Mobile
{
public static void main(String args[])throws IOException
{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
double a;b=0;
System.out.println("Enter ICCID or Sim No.");
a=double.parsedouble(in.readLine());
if(a=89912507111140687941)
b=7277526804;
else
if(a=89915241100005705108)
b=8084698160;
else
if(a=89912507111140687958)
b=7277526805;
else
if(a=89912502113154600856)
b=9852994726;
else
if(a=89912502113154600989)
b=9852999686;
else
b=121 
system.out.println("Your Mobile Number "+b);
}
}

`

2
Contributors
1
Reply
2
Views
4 Years
Discussion Span
Last Post by stultuske
0

double a;b=0;

that's your problem.
you're trying to assign 0 to b, but you didn't declare what b is.

replace it by:
double a;
double b = 0;

well, actually, that's just your first problem:

a=double.parsedouble(in.readLine());

Java is very case sensitive, double is not the same as Double,
replace that line with
a = Double.parseDouble(in.readLine());

if(a=89912507111140687941)

or this:
to check a primitive for a value, you don't use the = operator, but == . if you only place 1 =, you're assigning (or trying to assign) a value to a. also: make sure you don't try to assign values that are to large for the variable.

b=121

here, you are missing a ';'

system.out.println("Your Mobile Number "+b);

it's not system.out.println(""); but System.out.println("");

two advices:
1. store your numbers as a String value, that way you won't have the problem about the input exceeding the limits of the variables. you will have to check for equality using the equals method, instead of == since it's an Object, not a primitive.
2. don't allow your main method to throw an exception, use a try-catch statement instead. your main method is the entry point of your application, and the very last place where you can catch and handle the exception and thus avoiding your application to crash when an exception is thrown. like this:

public static void main(String[] args){

try{
// your code here
}
catch(IOException ioe){
System.out.println("An IOException occured:");
ioe.printStackTrace();
}
catch(Exception e){
System.out.println("An exception occured: ");
e.printStackTrace();
}

}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.