Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners java exception handling
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


praveen kumar reddy.y
java exception handling
0 Answer(s)      4 years and 2 months ago
Posted in : Java Beginners


hi while i am compailing the program given below i am getting an error please help me as soon as possible

import java.io.*;
class insufbal extends Exception
{
public insufbal(String str)
{
super(str);
}
}

public class bank
{
private int acc_id;
int wd_amt;
private String acc_name;
private double acc_bal;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
public bank()
{
acc_id=0;
acc_name="";
acc_bal=0.0;
}
public void init()
{
String temp;
try
{
System.out.println("enter the account number");
temp=br.readLine();
acc_id=Integer.parseInt(temp.trim());
System.out.println("enter the account holder name");
acc_name=br.readLine();
System.out.println("enter initial account balance");
temp=br.readLine();
acc_bal=Integer.parseInt(temp.trim());
}
catch(IOException ie)
{
System.out.println(ie.getMessage());
}
}
public void deposit()
{
String temp;
try
{
System.out.println("enter the deposit amount");
temp=br.readLine();
acc_bal+=Double.parseDouble(temp.trim());
}
catch(IOException ie)
{
System.out.println(ie.getMessage());
}
}
void withdraw() throws insufbal
{
String temp;

System.out.println("Enter the withdrawl amount");
temp=br.readLine();
wd_amt=Integer.parseInt(temp.trim());
if(acc_bal>wd_amt)
{
acc_bal=acc_bal-wd_amt;
}
else
{
insufbal insb=new insufbal("insuficient balance inyour account");
throw insb;
}
}
public void show()
{
System.out.println("\n Account Details");
System.out.println("------------------");
System.out.println("Account number:"+acc_id);
System.out.println("Ac_holder name:"+acc_name);
System.out.println("Balance:"+acc_bal);
}
public static void main(String args[])throws IOException
{
bank b=new bank();
b.init();
b.deposit();
b.show();
try
{
b.withdraw();
}
catch(insufbal insb)
{
System.out.println(insb.getMessage());
}
b.show();
}
}


Advertisement
View Answers

Related Tutorials/Questions & Answers:
Java exception handling
Java exception handling  what are the constraints imposed by overriding on exception handling
Exception Handling - Java Beginners
Exception Handling  hi,can u pls make me understand d clear cut difference between throw n throws keyword... n how can we make our own exception..i... want to force an exception then we use throw keyword. the throw keyword is used
Advertisements
Exception Handling in java
Exception Handling in java  what is advantage to catch smaller exception first and then normal exception. I mean we normally catch SQLException first and then Exception.   Hi, The exceptions should be from
Java exception handling
Java exception handling  How does a try statement determine which catch clause should be used to handle an exception
Java exception handling
Java exception handling  How does a try statement determine which catch clause should be used to handle an exception
Java exception handling
Java exception handling  What is the difference between throw and throws keywords
Java exception handling
Java exception handling  What is the catch or declare rule for method declarations
Java exception handling
Java exception handling  What classes of exceptions may be caught by a catch clause
Java exception handling
Java exception handling  Does the order of placing catch statements matter in the catch block
Java exception handling
Java exception handling  What happens if a try-catch-finally statement does not have a catch clause to handle an exception that is thrown within the body of the try statement
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
Java null pointer exception handling
Java null pointer exception handling   What is a java.lang.NullPointerException? Why do we use this exception class and when it occurs in any java... pointer exception handling What is Java NullPointerException? In Java
java Exception handling - Java Beginners
java Exception handling  what is the difference between throw and throws keywords
java Exception handling - Java Beginners
java Exception handling  what is the difference between throw... an exception manually where as throws is used in the case of checked exceptions to re-intimate the compiler that we have handled the exception. For more information
exception handling
exception handling   Give the exception hierarchy of Java.   Please visit the following links: http://www.roseindia.net/java/java-exception/exception-java.shtml http://www.roseindia.net/java/exceptions/exception
exception handling
exception handling  explain about exception handling
java exception handling - Java Beginners
java exception handling  hi while i am compailing the program given below i am getting an error please help me as soon as possible import java.io.*; class insufbal extends Exception { public insufbal(String str) { super
Java : Exception Handling
Java : Exception Handling In this section we will discuss about  JAVA Exception Handling with simple example. Exception Handling : An exception... such file which doesn't exist. By default it is handled by java runtime
Java Exception - Exception Handling in Java
Java Exception - Exception Handling in Java  ... code you will see that how the exception handling can be done in java program...;}   } } Download Exception Handling
exception handling
exception handling  could you please tell me detail the concept of exception handling
exception handling
exception handling  What is an exception and what are the advantages of exception handling mechanism.   Java Exception Exception are the runtime errors. Advantages: 1)Exception provides the means to separate
How to make a design document for exception handling in java
How to make a design document for exception handling in java  How to make a design document for exception handling
 

 

 

DMCA.com