0% found this document useful (0 votes)
5 views3 pages

Visual J++ Maturity Calculator Guide

This document provides instructions for creating a maturity calculator application in Visual J++. It walks through setting up a new project called "MaturityCalculator", adding controls like labels, text boxes and buttons to a Form, writing code to perform the calculation in the calculate button's click event, and testing the application. The instructions conclude by listing what should be turned in: a screenshot of the working Form with a sample calculation and tooltip, and a printout of the Java code for the project.

Uploaded by

Shafiqul Islam
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Visual J++ Maturity Calculator Guide

This document provides instructions for creating a maturity calculator application in Visual J++. It walks through setting up a new project called "MaturityCalculator", adding controls like labels, text boxes and buttons to a Form, writing code to perform the calculation in the calculate button's click event, and testing the application. The instructions conclude by listing what should be turned in: a screenshot of the working Form with a sample calculation and tooltip, and a printout of the Java code for the project.

Uploaded by

Shafiqul Islam
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

Visual J++ 6.

0 Tutorial #1 - Maturity Calculator


Fall 1999 - Dr. Norman - August 0! 1999
1. Launch Visual J++ (note: you will need a diskette with about 100kb of space to save this project
!. "ile #$ %ew &roject
'. (n the %ew &roject window: )e sure the selected folder in the *+plorer panel (left side is
,-pplications, and that ,.indows -pplication, is selected in the ri/ht panel.
0. (n the %ew &roject window: 1han/e the ,%a2e, of the project to ,-:31alculator, (or4 if you prefer4 use
the te2porary 5*6V*6 (shared hard disk in the lab as ,7:38e2p "older31alculator999,. (:se your
na2e initials in place of the 999 in order to avoid duplicate calculator na2es bein/ saved by 2ultiple
students thus possibly corruptin/ your work. %otice that the ,Location, chan/es also as you type.
8he ,Location, beco2es the ,path, for this new project.
;. (n the %ew &roject window: 1lick ,<pen, button. =oin/ so will take you back to the J++ desktop and
you will see your new project in the ,&roject *+plorer, window on the upper ri/ht side of the desktop.
>. (n the &roject *+plorer window (upper ri/ht side: 1lick on the plus (+ si/n to reveal the "[Link]
file in the *+plorer window.
?. =ouble click on the "[Link] file in the *+plorer window to reveal a blank for2 in the 2iddle of the
desktop. (%ote: @ou 2ay have to wait about '0 secondsAbe patient
B. 6i/ht Couse 1lick on the blank "or2 and select View 1odeD 8he Java code should now be displayed.
5croll down to see all of the ;; lines of Java code. %otice the section of the code in the E6*@
back/round. 8his is the code /enerated for the "<6C and should not be chan/ed by you.
9. 1lick the 58-68 icon ( to watch your for2 launch (e+ecute. .hen the blank for2 appears
so2ewhere on your screen4 click the 1lose icon ( on the blank for2. 8his will return you to desi/n
2ode. (%ote: @ou 2ay have to wait about '0 secondsAbe patient (you 2ay /et ,low virtual 2e2ory,
2essa/eAjust i/nore it
10. =ouble click on the "[Link] file in the *+plorer window a/ain to reveal a blank for2 in the 2iddle
of the desktop.
11. %ow it is ti2e to add controls to the for2 for the Caturity 1alculator.
1!. (n the &roperties window (lower ri/ht hand side of desktop chan/e the 8*98 property of the "or21
control to ,Caturity 1alculator # @our %a2e, si2ilar to the sa2ple above. -lso4 chan/e the
,start&osition, property for the "or2 to ,1enter 5creen,.
1'. <n the J++ 8oolbar (left side of desktop 2ake sure that the ."1 1ontrols 8ab is selected to reveal
all of the fa2iliar controls (te+t bo+es4 co22and buttons4 labels4 edit bo+es4 etc.
10. -dd 0 L-)*L controls and chan/e their 8*98 property values to look like the te+t on the sa2ple for2
above. ((f you do not have enou/h disk space you 2ay /et ,unable to save to disk, error 2essa/eA
be carefulAthis 2ay be deadly to your projectFFF
1;. -dd ' *=(8 )<9es (Visual )asic calls these 8*98 )<9*5 and chan/e their na2es to: edt(nvest4
edt(nterest4 edt@ear. -lso4 be sure to )L-%G out (erase the 8*98 property value for each bo+.
1>. -dd 1 1<CC-%= ):88<% and chan/e its %-C* to c2d1alculate and its 8*98 to H1alculate (the
H character will cause an underline to appear under the capital 1 on the button
1?. -dd 1 2ore L-)*L control used to display the calculated 2aturity value. 1han/e the na2e of this
control to lblCaturity. 1han/e its 8*98 property so it has %< value (e2ptyD chan/e its )-1G1<L<6
to ,white, (usin/ the palette tabD chan/e its )<6=*6 58@L* to ,"i+ed 'd,. %ow4 this control should
look just like the ' *=(8 )<9es on the for2.
1B. -dd 1 8<<L 8(& control to the for2 (place it near the botto2 of the for2Ait will not display when you
run the application. %ow you can add a 8<<L 8(& to any control on the "or2. 5o4 select the
followin/ controls in the &roperties window (lower ri/ht hand corner of desktop4 locate the 8<<L 8(&
property for the control and add the followin/ tool tips:
edt(nvest control add ,*nter an (nvest2ent -2ount,
edt(nterest control add ,*nter an (nterest &ercent such as B.? (B.?I,
edt@ear control add ,*nter the nu2ber of years such as ;.; (; and a half years
1J. 6ena2e the "or21. 8o do so4 in the *+plorer window (upper ri/ht side of desktop4 double click on
"[Link] (or ri/ht click on the "[Link] na2e and select ,rena2e, and then chan/e the na2e of
this for2 to [Link].
!0. 5witch back to the V(*. 1<=* window to see the J++ code. Locate the followin/ J++ source code
and 2ake the followin/ code chan/es:
public class "or21 e+tends "or2 chan/e to public class 1alculator e+tends "or2
public "or21( chan/e to public 1alculator(
8his ne+t line chan/e is found after the E6*@ )-1GE6<:%= code near the end of the pro/ra2
code:
-[Link](new "or21(D chan/e to -[Link](new 1alculator(D
!1. 1lick the ,2ultiple disks, icon on the tool bar (ne+t to the scissors to 5-V* all your work.
!!. 5elect ,)uild, on the 2ain Cenu and then select the ,)uild, option. J++ will now build (co2pile to byte
code your application. @ou 2ay see an error ,5pecified 2ain class K"or21K not found, appear in the
8-5G L(58 (botto2 center window of the desktopD below the code or for2 # i/nore this error. )e
patient as this step 2ay be slowF
23. &ress the 5tart icon ( to start your application. @ou 2ay /et another error # 5olution packa/e # &ress
<G button to i/nore this error. @ou 2ay then /et the 1alculator &roperties .indow display # if you do4
si2ply click the <G button on this window. @our Caturity 1alculator for2 should now appear # be
patient as this step 2ay be slow.
!0. 5top the 1alculator and return to desi/n 2ode and display the 1alculator "or2 window. =ouble click
on the 1alculate co22and button which will take you to the J++ code window and put you in the
2iddle of a newly created 2ethod called c2d1alculateL1lick as shown below:
private void c2d1alculateLclick(<bject source4 *vent e
M
N
(nsert the followin/ code on lines between the brackets M N of this 2ethod:
=ouble dbl(nvest4 dbl(nterest4 dbl@ear4 dbl6esultD
double d6esult O 0D
dbl(nvest O new =ouble(edt(nvest./et8e+t(D
dbl(nterest O new =ouble(edt(nterest./et8e+t(D
dbl@ear O new =ouble(edt@ear./et8e+t(D
d6esult O dbl([Link]( P [Link]((1 + dbl([Link](Q0004(0 P
dbl@[Link](D
dbl6esult O new =ouble(d6esultD
lblCaturity.set8e+t(dbl6esult.to5trin/(D
!;. 5ave your work. =o another ):(L=[Link] for any errors in the task [Link]+ and build a/ain if
necessary.
!>. 5tart the 1alculator a/ain and this ti2e you should be able to enter data into the for2 and have it
calculate the 2aturity value. )e sure to use: !!;00 for invest2ent4 B.? for percent and ;.; for years
like the sa2ple at the be/innin/ of this tutorial.
!?. .hat to turn in to the instructor ((f you end up with 2ore than one pa/e4 put the pa/e with the
1alculator "or2 as the first pa/e and staple the J++ code pa/es to/ether behind it:
-. - copy of the 1alculator "or2 .(87 the above nu2bers (!!;004 B.?4 ;.; and the resultin/
2aturity calculation in the for2 alon/ with <%* 8<<L 8(& bein/ shown (put your 2ouse over an
edit bo+ before doin/ the -lt#&rint5creen. @ou will need to do an -lt#&rint5creen while your for2
is runnin/ in order to copy it to the 1lipboard and then paste it into a .ord docu2ent for printin/.
). - copy of the J++ code (not includin/ the code in E6-@ or after the E6-@ area. 8o do this you
will need to hi/hli/ht the code startin/ with the ,i2port, state2ents and down to the E6-@ area
and copy it to the clipboardD then paste it into a .ord docu2ent and print it. (-lternatively4 you
2ay want to print the entire J++ code includin/ the code in the E6-@ area si2ply by selectin/
&rint fro2 the "ile 2enu but that will take a few pa/es to print it all.
!B. 5ave all your work. Geep it on a diskette for future referenceF
"ND o# T$T%&'A(

You might also like