Results 1 to 2 of 2
  1. #1
    yousuf89 is offline Member
    Join Date
    May 2013
    Posts
    2
    Rep Power
    0

    Default RMI question on withdraw deposit and show balance

    can anyone help me on this?

    Create an RMI application which allows a user to perform three banking operations such as Deposit, Withdrawal and Getting latest account balance. The application accepts a double amount as input for the first two operations and shows the status information after performing the actions. The third operation will display the account balance on execution. You are required to complete the application based on the following requirements:
    > Your remote interface should have three separate methods for three different operations.
    > Remote methods should be implemented on Server.
    > Client can able to provide the number of inches to be converted on a textfield and get the result in centimeter on another textfield.
    > Server should provide the required outputs to the client.
    > An application/applet with appropariate GUI shouild be implemented on Client (mandatory) and Server (Optional)
    What I know is to create a GUI application with an RMI that allows you to withdraw,deposit and show balance


    the professor a basic exercise of RMI for currency converter:

    these are the steps that I know:
    http://i277.photobucket.com/albums/k...ps9d519601.png

    the codes for them:

    rClient

    Java Code:
    import java.io.*; 
    import java.rmi.*; 
    
    public class rClient 
    { 
    public static void main(String args[]) 
    { 
    double amount=0; 
    BufferedReader is = new BufferedReader(new InputStreamReader(System.in)); 
    System.out.print("Enter an amount: OR"); 
    try 
    { 
    amount = Double.parseDouble(is.readLine()); 
    }catch(IOException e){} 
    
    try 
    { 
    Object o = Naming.lookup ("rmi://127.0.0.1/rConvert"); 
    rConverter r =(rConverter)o; 
    System.out.println("Converted to: $"+r.Convert(amount)); 
    } 
    catch (Exception e) 
    { 
    System.out.println("ERROR " + e.getMessage()); 
    e.printStackTrace(); 
    } 
    } 
    }

    rConverter
    Java Code:
     import java.rmi.*; 
    
    public interface rConverter extends Remote 
    { 
    public double Convert(double x) throws RemoteException;

    rConverterImpl
    Java Code:
    import java.net.*; 
    import java.rmi.*; 
    import java.rmi.server.*; 
    
    public class rConverterImpl extends UnicastRemoteObject implements rConverter 
    { 
    public rConverterImpl() throws RemoteException 
    { 
    super(); 
    } 
    
    public static void main(String args[]) 
    { 
    try 
    { 
    rConverterImpl rc = new rConverterImpl(); 
    Naming.rebind("rConvert",rc); 
    System.out.println("Remote Converter Started..."); 
    } 
    catch (RemoteException e) 
    { 
    System.out.println("RemoteException: " + e.getMessage()); 
    e.printStackTrace(); 
    
    } 
    catch (MalformedURLException m) 
    { 
    System.out.println("URL Problem: " + m.getMessage()); 
    m.printStackTrace(); 
    } 
    } 
    
    public double Convert(double f) 
    { 
    double rate = 2.50; 
    System.out.println("Remote Conversion Request: OR" + f); 
    return(f*rate); 
    } 
    }
    I tried to do it similar but didn't really worked out, can anyone help me please?

  2. #2
    yousuf89 is offline Member
    Join Date
    May 2013
    Posts
    2
    Rep Power
    0

    Default Re: RMI question on withdraw deposit and show balance

    This is what I've done but I'm not sure if its correct:


    This is for the Interface:
    Java Code:
    import java.rmi.*; 
    public interface Intf extends Remote 
    { 
    double withdraw(double a,double amt)throws RemoteException; 
    double deposit(double b,double amt)throws RemoteException; 
    double balance(double amt)throws RemoteException; 
    }
    This is for the Implementation:
    Java Code:
    import java.net.*;
    import java.rmi.*;
    import java.rmi.server.*;
    
    public class Impl extends UnicastRemoteObject implements Intf 
    { 
    public Impl()throws RemoteException 
    {
    super();
    }
    
    public static void main(String args[]) 
    {
    try
    {
    Impl bankimpl=new Impl(); 
    Naming.rebind("BankServer",bankimpl); 
    System.out.println("Server is ready to go"); 
    }
    
    catch(Exception e) 
    {
    System.out.println("Exception :"+e); 
    }
    }
    
    	
    public double withdraw(double a,double amt)throws RemoteException 
    { 
    amt=amt-a; 
    return(amt); 
    }
    
    public double deposit(double b,double amt)throws RemoteException 
    { 
    amt=amt+b; 
    return(amt); 
    }
    public double balance(double amt)throws RemoteException 
    { 
    return(amt); 
    }
    }
    I done the Client Part Also (BUT NOT COMPLETE)
    I used the GUI and GridLayout in the Client Part

Similar Threads

  1. Deposit Money
    By spyxdaxworld in forum New To Java
    Replies: 2
    Last Post: 10-26-2012, 07:52 AM
  2. How to withdraw a specific from a String?
    By equal in forum New To Java
    Replies: 6
    Last Post: 05-29-2011, 10:02 PM
  3. Replies: 4
    Last Post: 04-20-2011, 01:17 AM
  4. jdom question , show xml
    By pipikrk in forum New To Java
    Replies: 11
    Last Post: 05-05-2010, 03:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •