Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PART 2 Question 1 [40 pts]: Remote Method Invocation Design and implement a RMI-based Client/Server application for converting dollar ($) to Lebanese Lira (L.L). You

PART 2

Question 1 [40 pts]: Remote Method Invocation

Design and implement a RMI-based Client/Server application for converting dollar ($) to Lebanese Lira (L.L). You must: (1) Create a remote interface called CurInterface, (2) a class called CurImplementation to implement the remote interface, (3) a server class called CurServer for hosting the method, (4) and a client class where the remote call is done.

Your interface includes one method called convertToLira. The method takes two parameters: the amount in dollars and the exchange rate. For example, convertToLira(12, 24000) convert 12$ to Lebanese Lira using the exchange rate 1$=24000LL. Thus, the method returns 12*24000=288000 L.L

Question 2 [10 pts]: Web services

Mirna wants to solve the problem in part 2-question 1 using a webservice called convertToLira. She needs your help. Write few sentences to explain to her the main steps to create this service and to solve this problem. Do NOT implement the application.

PART 3

Question 1 [35pts]: Multithreading

Write a java multithreaded VowelServer application that reads a sentence from the client and counts the numbers of vowels (Use port 10008). The vowels are a, e, I, o, u. For example, if the client sends I am Mourad, the server returns the following message:

Server received: I am Mourad

Number of Vowels is 5

Below are some useful methods

  • PrintWriter out=new PrintWriter(clientSocket.getOutputStream(),true);
  • BufferedReader in=new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
  • char y=S.charAt(x) to find the character at index x in a string S.
  • y=Character.toLowerCase(y); to convert a char to lower case

-------------------------------------------------------------------------------------

The client code is given below

package vowelclient;

import java.io.*;

import java.net.*;

import java.util.Scanner;

public class VowelClient {

public static void main(String[] args) throws IOException {

String serverHostname = new String ("127.0.0.1");

Socket echoSocket = new Socket(serverHostname, 10008);

PrintWriter out = new PrintWriter(echoSocket.getOutputStream(), true);

BufferedReader in = new BufferedReader(new InputStreamReader(echoSocket.getInputStream()));

Scanner stdIn = new Scanner(System.in);

while(true){

System.out.print("Enter a sentence:");

String userInput=stdIn.nextLine();

out.println(userInput);//send the message to server

System.out.println(in.readLine());//receive the response from server

}

} }

Fill in the blanks the solution of Part 2

Or upload the .java files

PART 2- Question 1

import java.rmi.*;

public interface CurInterface . {

..

..

}

import java.rmi.*;

public class CurImplementation . {

..

..

..

..

..

..

..

..

}

import java.rmi.*;

public class CurServer {

public static void main(String[] args) {

..

..

..

..

..

..

..

}}

import java.rmi.Naming;

..

public class CurClient {

public static void main(String[] args) {

..

..

.. }}

PART 3- Question 1

package vowelserver;

import java.io.*;

import java.net.*;

public class VowelServer .{

..

..

private VowelServer (..){

..

..

}//end constructor

public static void main(String[] args) throws IOException{

ServerSocket serverSocket = null;

try {

..

..

..

..

..

..

} catch (IOException e) {

System.err.println("Error");

System.exit(1);

}

finally {

// serverSocket.close();

}//end finally

}//end main

public void run() {

try {

PrintWriter out = new PrintWriter(clientSocket.getOutputStream(),true);

BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));

..

..

..

..

..

..

..

..

..

out.close();

in.close();

clientSocket.close();

}catch (IOException e){

System.err.println("Problem with Communication Server");

System.exit(1); }

}//end run

}//end class

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions