A server program written in one language (for example C++) provides the implementation of a BLOB object that is intended to be accessed by clients that may be written in a different language (for example Java). The client and server computers may have different hardware, but all of them are attached to an internet. Describe the problems due to each of the five aspects of heterogeneity that need to be solved to make it possible for a client object to invoke a method on the server object.
What will be an ideal response?
As the computers are attached to an internet, we can assume that Internet protocols deal with differences in
networks.
But the computers may have different hardware - therefore we have to deal with differences of
representation of data items in request and reply messages from clients to objects. A common standard will be
defined for each type of data item that must be transmitted between the object and its clients.
The computers may run different operating systems, therefore we need to deal with different operations
to send and receive messages or to express invocations. Thus at the Java/C++ level a common operation would
be used which will be translated to the particular operation according to the operating system it runs on.
We have two different programming languages C++ and Java, they use different representations for data
structures such as strings, arrays, records. A common standard will be defined for each type of data structure
that must be transmitted between the object and its clients and a way of translating between that data structure
and each of the languages.
We may have different implementors, e.g. one for C++ and the other for Java. They will need to agree
on the common standards mentioned above and to document them.
You might also like to view...
What is a test scenario? Where should you look for information to build test scenarios?
What will be an ideal response?
The hardware that allows the mobile computing device to detect a wireless signal is a(n) ____.
A. access point card B. CompactFlash card C. flash memory D. wireless network interface card
The most common form of secondary storage is ________________.
a. a disk drive b. the CPU c. RAM d. all of the above
A bank wants to show its customers how much they would need to invest to achieve a specified financial goal (future value) in 5, 10, 15, 20, 25 or 30 years. Users must provide their financial goal (the amount of money desired after the specified number of years has elapsed), an interest rate and the length of the invest- ment in years. Create an application that calculates and displays the principal (initial amount to invest) needed to achieve the user’s financial goal. Your application should allow the user to invest money for 5, 10, 15, 20, 25 or 30 years. For example, if a customer wants to reach the financial goal of $15,000 over a period of 5 years when the interest rate is 6.6%, the customer would need to invest $10,896.96 as shown in Fig. 10.28.
a) Copying the template to your working directory. Copy the C:\Examples\Tutorial10\Exercises\PresentValue directory to your C:\SimplyJava directory.
b) Opening the template file. Open the PresentValue.java file in your text editor.
c) Customizing the JSpinner. You must customize the JSpinner to display the number of years. The name of this JSpinner is yearsJSpinner. This JSpinner should dis- play every multiple of 5 from 0 to 30, inclusive. Modify line 83 so that the initial value in the JSpinner is 0, the minimum value is 0, the maximum value is 30 and the step size is 5. In line 84, insert code to set the bounds property to 130, 95, 100, 20.
d) Customizing the JTextArea. You must customize the JTextArea that will display the various amounts needed on deposit. The name of this JTextArea is amountNeededJ- TextArea. Insert a blank line at line 94. On line 95, insert code to set the bounds property to 20, 155, 320, 115. On the next line, insert code to set amountNeeded- JTextArea’s editable property to false.
e) Retrieving input from a JSpinner. In line 133, access the JSpinner’s value property and use the ( Integer ) cast to convert the result to an object of type Integer. Store the result in Integer object integerObject. Insert a blank line at line 133. On line 134, retrieve the int data in integerObject, and store this data in int variable
years.
f) Completing a for statement header. In line 140 you will see a for statement header with only two semicolons. Before the first semicolon, declare and initialize variable counter to 5. Before the second semicolon, enter a loop-continuation condition that will cause the for statement to loop until counter has reached the number of years specified by the user. After the second semicolon, enter the increment of counter so that the for statement executes for every fifth year.
g) Calculating present values. You will now calculate the amount needed to achieve the future value for each five-year interval. To do this, you will need to implement the following formula within the for statement:
p = a / (1 + r) n
where
p is the amount needed to achieve the future value
r is the annual interest rate
n is the number of years
a is the future value amount (the amount the user would like to have after n years)
In lines 142–143, use the Math.pow method (as well as the variables defined for you in lines 129 and 131) to calculate the present value needed for the current number of years. Use two lines for clarity. In lines 144–145, use the append method to output the present value calculated in the application’s JTextArea. Use the DecimalFormat object (dollars) created for you in line 137. Use two lines for clarity.
h) Saving the application. Save your modified source code file.
i) Opening the Command Prompt window and changing directories. Open the Com- mand Prompt window by selecting Start > Programs > Accessories > Command Prompt. Change to your working directory by typing cd C:\SimplyJava\PresentValue.
j) Compiling the application. Compile your application by typing javac PresentValue.java.
k) Running the completed application. When your application compiles correctly, run it by typing java PresentValue. Input a future value, interest rate and a number of years, then click the Calculate JButton. View the results to ensure that the correct number of years is displayed, and that the initial deposit results are correct.
l) Closing the application. Close your running application by clicking its close button. m) Closing the Command Prompt window. Close the Command Prompt window by clicking its close button.