![]() |
|
|||||||
|
|
Thread Tools | Search this Thread | Rate Thread |
|
#1
|
|||
|
|||
i really need help in coding this applet.. i gave up !! plz helpcan any1 help me in coding this following applet question:
(ASAP) Write a windowed application to fulfill the following requirements. This applet will be built upon the topics we have studied in lectures: Java Applications, Methods, Classes Arrays, AWT Components plus methods in the Java Math class, e.g., square root, compound interest, etc. User interface: •Your program should prompt the user to enter the price of a house, the number of years for which they would like to make payments towards re-paying the mortgage for the house, the interest rate charged for mortgage, and the down-payment amount. •Your program should use check-buttons to allow the user to select one of two types of loans – the SIMPLE INTEREST LOAN or the COMPOUND INTEREST LOAN •Your program should then use all the information provided in the above two bullet-points to calculate the following: 1.Total amount the borrower will pay at the end of the borrowing period – in Dirham 2.Monthly loan payment amount in Dirham 3.Amount to be saved if complete loan is paid in half the re-payment period indicated by borrower. 4.Amount to be saved if complete loan is paid in ¾ of the time indicated by the borrower. •The above four pieces f information should be displayed as labels inside a results panel. The results panel should not overlap the data-input panel but both panels should be included in the same window. Technical requirements: Your program should perform the following. 1.Obtain user inputs using AWT components. 2.Create two separate classes to determine the simple interest loan’s results, and the compound interest loan’s results 3.Group all outputs into the same CLASS. This class should be different from the one in which user inputs are captured. |
|||
|
#2
|
||||
|
||||
Re: i really need help in coding this applet.. i gave up !! plz helphi 123awd,
Welcome to the GIDForums. You should create two separate classes as you said for your simple interest and compound interest. How would you create a simple interest class? Create four variables for price, rate of interest, years and the downpayment. Create three methods. One to get the inputs(you can use the constructor fo this), one to print or return the output and one to calculate the simple interest. Do the same for your compound interest class. Use two different files for simple and compound interest classes. The third class is the applet class where you use the objects of simple and compound interest. Lets start with applets. How to create awt components and use them? import java.awt.*; for using the awt components. The AWT supplies the following UI components: # Buttons (java.awt.Button) # Checkboxes (java.awt.Checkbox) # Single-line text fields (java.awt.TextField) # Larger text display and editing areas (java.awt.TextArea) # Labels (java.awt.Label) # Lists (java.awt.List) # Pop-up lists of choices (java.awt.Choice) # Sliders and scrollbars (java.awt.Scrollbar) # Drawing areas (java.awt.Canvas) # Menus (java.awt.Menu, java.awt.MenuItem, java.awt.CheckboxMenuItem) # Containers (java.awt.Panel, java.awt.Window and its subclasses) (extracted from java.sun.com) So to use a container, simply create an instance of it. For example, to create a TextField, you can create new member variable of the class: Textfield input; Then in your init() in the applet(You can find more information about applet Applets, you can enter this: input=new TextField(); Create a new layout. Use a simple Grid Layout(You know layouts dont you?) If you dont know about layouts, check this link:Layouts setLayout(new GridLayout(x,y)); where you should replace x and y according to the number of components you are displaying. Then add the text field to the applet. add(field); validate(); Invoking validate once after adding one or more Components to an applet ensures that the Components draw themselves onscreen. you dont have to put like java.awt.TextField because you have already imported java.awt.*; Similarly you can use the various components available. You can use ActionListener to check whether the user had clicked a button or many other user actions. The various user actions are: action() (Event.ACTION_EVENT) mouseEnter() (Event.MOUSE_ENTER) mouseExit() (Event.MOUSE_EXIT) mouseMove() (Event.MOUSE_MOVE) mouseDown() (Event.MOUSE_DOWN) mouseDrag() (Event.MOUSE_DRAG) mouseUp() (Event.MOUSE_UP) keyDown() (Event.KEY_PRESS or Event.KEY_ACTION) keyUp() (Event.KEY_RELEASE or Event.KEY_ACTION_RELEASE) gotFocus() (Event.GOT_FOCUS) lostFocus() (Event.LOST_FOCUS) handleEvent() (all event types) Create action commands for the inputs so that you can identify the action: setActionCommand("enable"); Then create instances of the simple and compound interest classes. Here is the main program: JAVA Code:
I hope you understood what i have typed. You can find about more information of all these in the sun java documentation. Sun Java documentation Regards, Paramesh. PS: Some of the awt component tutorials are missing in the documentation. They are available as download instead. Here is the link for old awt documentation: AWT This is because programmers dont use awt nowadays. They use JFC instead because they are lightweight components. __________________
Don't walk in front of me, I may not follow. Don't walk behind me, I may not lead. Just walk beside me and be my friend. |
|
#3
|
|||
|
|||
Re: i really need help in coding this applet.. i gave up !! plz helpHey man thanks alot for your help but the thing is that what is written here is so advanced and i dont understand 90% of whats written here and i really need this program to be working in max 2 days i really dont know what to do...so please help it is really important
Thanks man ... |
|
#4
|
||||
|
||||
Re: i really need help in coding this applet.. i gave up !! plz helpHi awd,
Quote:
I replied that way because : Quote:
So, if you tell us what is your progress in this past 18 days, we could help you in a much efficient way. You could also post your code so that we could modify it in a way you understand. Best Regards, Paramesh. __________________
Don't walk in front of me, I may not follow. Don't walk behind me, I may not lead. Just walk beside me and be my friend. |
|
#5
|
|||
|
|||
Re: i really need help in coding this applet.. i gave up !! plz helpHi Paramesh hope all is good:
I have done it the way we studied the material but the thing is that there are few parts that i didnt know how to do ....i will attach the java file i have done but the missing parts are 1.Check buttons for the simple and comp interest 2.cutting it into different classes (2.Create two separate classes to determine the simple interest loan’s results, and the compound interest loan’s results) 3.Group all outputs into the same CLASS. This class should be different from the one in which user inputs are captured i didnt evenunderstand this part. I am really thankful and I really appreciate your help another thing can you check the output,, it looks really weird when you use a large number of years for instance 7,8,9,10 the output isnt organized and i dont know how to format it, |
|
#6
|
||||
|
||||
Re: i really need help in coding this applet.. i gave up !! plz helpHi awd,
Here is a very quick reply: You can add radiobuttons by: JAVA Code:
JAVA Code:
Then we should initialize it in the createUserInterface() method like this: JAVA Code:
Then we should create a itemlistener for the radio buttons. This is done by creating a class RadioButtonHandler. Before that, we should add the components to the contentPane. like this: JAVA Code:
The handler class is similar to your anonymous inner class. its definition is like this: JAVA Code:
Now to the simple and compound interest classes: Create a new file simpleInterest.java(it should be in the same directory as MortCalc.java) create a simpleInterest class like this: JAVA Code:
Similarly create one for compoundInterest. Calculate the interest and other variables using the calculate method. you should pass the corresponding parameters for the calculate function. Then in the MortCalc, add the classes like this: JAVA Code:
You can modify your calculateJButtonActionPerformed like this: 1. check if simpleinterest radiobutton is selected. If it is selected, then calculate the simple interest by calling the method sim.calculate(..) 2. If compoundinterest is selected, do the same way. So if it is simple, display the answer by using the simple class members. i.e simple.interest will give you the interest. simple.price will give you the price and so on. This is a very quick reply because i am going out now(be back in 3 hrs). Just to give you some information. Regards, Paramesh. __________________
Don't walk in front of me, I may not follow. Don't walk behind me, I may not lead. Just walk beside me and be my friend. |
|
#7
|
|||
|
|||
Re: i really need help in coding this applet.. i gave up !! plz helpHey Mr. Paramesh:
I would like to thank you for your help and for your fast replies....i tried to use the code above in my program and it didnt work... So it would be really great if it was added into my Java file that i have posted... This assignment is due tomorow and its really important and weights alot towards my final grade...I appreciate your understanding... thanks again..... AWD |
|
#8
|
||||
|
||||
Re: i really need help in coding this applet.. i gave up !! plz helpHi awd,
Hope your assignment submission went well. Sorry, I was not able to reply because i went to my hometown. If you still have any doubts, post again to clarify. Best Regards, Paramesh. __________________
Don't walk in front of me, I may not follow. Don't walk behind me, I may not lead. Just walk beside me and be my friend. |
Recent GIDBlog
Accepted for Ph.D. program by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need help with Simple 1D Array coding project | rho | C++ Forum | 2 | 27-Jun-2005 20:05 |
| need help with some c++ coding.. | vivina | C++ Forum | 9 | 14-Dec-2004 00:58 |
| PHP/MySQL coding issue | cmarti | MySQL / PHP Forum | 3 | 26-Jul-2004 09:01 |
| Pls help in this coding. | harsha | C++ Forum | 5 | 08-Apr-2004 21:48 |
| coding a word with a givin factor | funnyf | C++ Forum | 2 | 13-Jan-2004 09:32 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The