Creating a calculator
i am trying to create a calculator and I am not sure how to set up the multiply, divide, add, subtract or the equal keys. i am currently trying " inputField.getText" to get the number , but how do i then get the second number from the same field after pressing one of the functions and set that up so that the equal key will give me the answer???? Any help would be appreciated
public void actionPerformed(ActionEvent event);
if(event.getSource() == sevenButton)
seven();
if else(event.getSource() == eightButton)
eight();
if else(event.getSource() == nineButton)
nine();
if else (event.getSource() == divideButton)
divide();
if else(event.getSource() == fourButton)
four();
if else(event.getSource () == fiveButton)
five();
if else(event.getSource () == sixButton)
six();
if else (event.getSource () == multiplyButton)
multiply();
if else (event.getSource () == oneButton)
one();
if else(event.getSource () == twoButton)
two();
if else (event.getSource () == threeButton)
three ();
if else(event.getSource () == minusButton)
minus();
if else(event.getSource () == zeroButton)
zero();
if else(event.getSource () == equalsButton)
equals();
if else(event.getSource () == addButton)
add();
{ //end actionperformed
public void seven()
inputField.setText(" ");
inputField.setText("7");
public void eight()
inputField.setText(" ");
inputField.setText("8");
public void nine()
inputField.setText(" ");
inputField.setText("9")'
public void divide()
num1 = Integer.parseInt(inputField.getText());
} //end class
Seems to me that a real calculator stores the number from the display somewhere when (e.g.) the Plus key is pressed, then when the Equals key is pressed it adds that stored number to the current display and displays the result. Why don't you imitate that behaviour?
Similar Messages
-
How to write the expression when create the calculated column?
Dear,
I want to create some calculated column in my attribute view, but I don't know how to write the code in the expression, is there any introduction about this part, how to use those function and how about the grammar in this expression code ? or is there any example about this calculated column?
Thanks for your sincerely answer.Hi Zongjie,
you can find some information about the creation of calculated columns in the HANA Modeling Guide (http://help.sap.com/hana/SAP_HANA_Modeling_Guide_for_SAP_HANA_Studio_en.pdf).
Within chapter 6.2.1 (Create Analytic Views) you can see under point 7 some basics and also a simple example. The same is also valid for Calculation Views.
Chapter 8.9 (Using Functions in Expressions) describes the different available functions.
You also can use the integrated search in the HANA Studio by clicking the "?" button in the button left corner. Then you get some links in the side panel with related information.
In general you can write your expression manually or you can just drag and drop the functions, elements, operators into the editor window. For example if you drag and drop the "if" function into the editor window you get "if(intarg,arg2,arg3)" inserted. The arguments can be replaced manually or also by drag and drop.
It is also worse to use the "Validate Syntax" button on top of the editor window. It gives you directly a feedback if your expression syntax is correct. If not you get some helpful information about the problem (ok, sometimes it is a little bit confusing because of the cryptic error message format ).
Best Regards,
Florian -
Hi
I am developing a discoverer report, I'm working with Oracle Discoverer 3.1 - User Edition, Version 3.1.26.01 (dce.dll 3.1.83) Oracle End User Layer 3.1.13.0.0.0
I got a column (Open Time) with date and time "DD-Mon-YY HH:MI AM", and I need to create a New Column (Closed Time) as a calculation. The first Closed Time is one minute less than the second Open Time.
And continue with the same procedure, Second Closed Time is one minute less than the third Open Time.
The Queue Job Num. "90" is when the job is completed.
Here is an example of the table:
Id Num ---- Country ----- Tel Num ---------- Open Time ---------------- Closed Time ---------- Queue Job Num ---- Time In Queue Job
----1 ------------ PR ------ 7870502397 ---- 10/22/20074:56 PM ------------ ???? ------------------------- 56 ----------- (Open Time) - (Closed Time)
----1 ------------ PR ------ 7870502397 ---- 10/23/2007 8:50 AM ----------- ???? ------------------------- 26 ----------- (Open Time) - (Closed Time)
----1 ------------ PR ------ 7870502397 ---- 10/24/2007 10:40 AM --------- ???? --------------------------76 ------------ (Open Time) - (Closed Time)
----1------------- PR ------ 7870502397 ---- 10/26/2007 2:24 PM ----------- ???? ------------------------- 46 ----------- (Open Time) - (Closed Time)
----1 ------------ PR ------ 7870502397 ---- 10/26/2007 4:15 PM -----10/26/2007 4:15 PM ---------- 90
I tried make a calculation,but I failed..
Pls, help me out.
Regards
NVega54Thank you Nilesh, to try to help me.
I don't have access to the database. I'm working with Oracle Discoverer 3.1 - User Edition, Version 3.1.26.01 (dce.dll 3.1.83) Oracle End User Layer 3.1.13.0.0.0. Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production.
The only information that I have is the Open Time of each Queue Job Num. And I need to create a calculation to get the Closed Time of each Queue Job.
The Closed Time in the first row is one minute less than the open time of the second row.
Id Num ---------- Open Time ---------------- Closed Time ---------- Queue Job Num ---- Time In Queue Job
----1 -------- 10/22/20074:56 PM --------------- ???? ------------------------- 56 ----------- (Open Time) - (Closed Time)
----1 -------- 10/23/2007 8:50 AM -------------- ???? ------------------------- 26 ----------- (Open Time) - (Closed Time)
----1 -------- 10/24/2007 10:40 AM ------------ ???? --------------------------76 ------------ (Open Time) - (Closed Time)
----1--------- 10/26/2007 2:24 PM -------------- ???? ------------------------- 46 ----------- (Open Time) - (Closed Time)
----1 -------- 10/26/2007 4:15 PM ------10/26/2007 4:15 PM ------------ 90
Thanks anyway for your help.
NVega54 -
How do you create a calculation that automatically updates changes?
Hi all,
I am trying to create a calculation using subtraction. This is how it is set out:
KM
-KG
=Field1
-Field2
=GM (fluid)
Under the calculate tab for Field 1, I have written in the Simplified field notation:
KM-KG
And under the calculate tab for =GM (fluid), I have written in the Simplified field notation:
Field1-Field2
And this all works perfectly providing I don't change any of the totals in the KM or KG or Field2 fields.
If I make changes in those fields they don't automatically update.
How do I make them automatically update?
Any assistance would be hugely appreciated.
Many thanks.
BridieTo set the field calculation order, first go into form editing mode (Tools > Forms > Edit) and then: Tasks > Other Tasks > Edit Fields > Set Field Calculation Order
Order the fields in the list to whatever makes sense for your form. Be sure to do this again once you have the form working like you want to make sure it's still set up correctly. -
How to create a calculated field
Hi. I'd like to know how to create a calculated field for a master- detail form. For example: having two db fields price and quantity, i created a the total item (price * quantity) as pl/sql function like this:
begin
:p13_item_total := :p13_price * :p13_quantity;
end;
However, the item is not calculated. It is not and instant calculation. I mean if i modify either price or quantity, how to recalculate item total immediatelyYou must submit the page to do it with PL/SQL. If you do not want to submit the page, you must do it with JavaScript.
Thanks,
Tyler -
Question to create a calculation to add three table's cells for a grand total
I need help with creating a calculation to add three tables. Table, 6, 7 and 8. The total of all tables should be in the last table where it says Total.
I would appreciate any help.
ThanksIf this is the resultyou are looking for the attached will help.
Steve
Please post LiveCycle Designer ES questions in that forum in the future. -
I need help! Need to create a calculator.
Can someone tell me if it's possible to create a calculator on a website? I'm doing a website for a concrete company, and the owner wants a calculator on there for large scale jobs and I HAVE NO IDEA how to do it! Thanks.
It is possible to create a calculator with Flash, to just about any complexity you like. The key to alot of it is learning how to utilize input textfields and variables, and possibly the Math functions in your coding. If the client will have options to choose from, like a drop list of material choices, then you'll also need to become familiar with coding and extracting selected values from components.
-
How do I create a calculator for options?
I'm trying to create a calculator that will give a total based upon different options that are selected. For instance:
Base Price is $250
Option A is $15
Option B is $20
Option C is $150
The Base Price would initially be shown as the total ($250), but when someone selects Option A and Option C, the total would change to reflect that ($415), preferably without using a database. Any ideas would be appreciated.
ThanksNot sure what you're trying to do? iMovie is an app and is located in a folder: the Application folder.
If you want to just create a folder for any movies you make, you can just do that in Finder: hit File and then "New Folder" - it'll show untitled and you can name it whatever you want. You could store it in your Documents folder inside the "Movies" folder or separately. -
Problem when creating a calculated column "Item has already been added"
Hi,
I built an a set of lists and custom content types which are made available under http://moss/callcenter. When I want to create a new calculated column for one of my custom content types i get the following error
Item has already been added. Key in
dictionary: 'Strasse_Strasse' Key being added: 'Straße_Straße'
This is rather strange as I don't even get as far as creating that new column. The error occurs right when I select the type calculated column, even before I enter a name for the new column. How ever, when I want to create a calculated column in root site collection (http://moss/) this error does not occur and I can create the new column.
Any ideas anyone?
Thank you,
Christophhi,
you can try below thing
http://blogs.msdn.com/b/timquin/archive/2009/02/11/sharepoint-item-has-already-been-added-key-in-dictionary-484-key-being-added-484.aspx
Whenever you see a reply and if you think is helpful,Vote As Helpful! And whenever you see a reply being an answer to the question of the thread, click Mark As Answer -
I am trying to create a calculation for my BI Project. I named it Quota Variance, chose Subtraction and clicked Next and nothing happens.
When I try to create any other type of object, I get the error message "Unable to Initialize QueryBuilder"
Is anyone else experiencing this?Hi,
I am also having the same problem. I have applied the patch for Oracle Database 9.0.2, I have successfully connected to the OLAP Server instance and done a MetaData Refresh.
This is the stack trace from JDeveloper when trying to create a BI Bean.
Unable to initialize QueryBuilder -
oracle.express.mdm.MetadataNotFoundException
oracle.olapi.metadata.MetadataObject oracle.express.mdm.MdmMetadataProvider$Holder.getMetadataObject()
MdmMetadataProvider.java:170
oracle.express.mdm.MdmObject oracle.express.mdm.MdmMetadataProvider.getMetadataObject(java.lang.String)
MdmMetadataProvider.java:410
oracle.express.mdm.MdmSchema oracle.express.mdm.MdmMetadataProvider.getRootSchema()
MdmMetadataProvider.java:548
oracle.express.mdm.MdmSchema oracle.dss.metadataManager.server.drivers.mdm._92.MDMMetadataDriverImpl_92.getMdmSchema()
MDMMetadataDriverImpl_92.java:1285
oracle.dss.metadataManager.common.MDObject oracle.dss.metadataManager.server.drivers.mdm._92.MDMMetadataDriverImpl_92.getRoot()
MDMMetadataDriverImpl_92.java:974
oracle.dss.metadataManager.common.MDRoot oracle.dss.metadataManager.server.drivers.mdm._92.MDMMetadataDriverImpl_92.addToObjectModeloracle.dss.metadataManager.common.MDRoot)
MDMMetadataDriverImpl_92.java:2261
oracle.dss.metadataManager.common.MDRoot oracle.dss.metadataManager.server.drivers.mdm.MDMMetadataDriverImpl.addToObjectModeloracle.dss.metadataManager.common.MDRoot)
MDMMetadataDriverImpl.java:283
void oracle.dss.metadataManager.server.MetadataManagerImpl.buildObjectModel()
MetadataManagerImpl.java:1092
oracle.dss.metadataManager.common.MDRoot oracle.dss.metadataManager.server.MetadataManagerImpl.attach(oracle.dss.metadataManager.common.MDRoot,oracle.dss.metadataUtil.PropertyBag)
MetadataManagerImpl.java:962
int oracle.dss.metadataManager.client.MetadataManager.attach(oracle.dss.metadataUtil.PropertyBag)
MetadataManager.java:866
int oracle.dss.metadataManager.client.MetadataManager.attach()
MetadataManager.java:792
oracle.dss.metadataManager.client.MetadataManager oracle.dss.addins.designer.BIDesignerImpl.getMetadataManager(boolean)
BIDesignerImpl.java:987
oracle.dss.metadataManager.client.MetadataManager oracle.dss.addins.designer.BIDesignerImpl.getMetadataManager(boolean, boolean)
BIDesignerImpl.java:927
void oracle.dss.addins.wizard.presentation.PresentationWizardContext.initQueryBuilder()
PresentationWizardContext.java:83
void oracle.dss.addins.wizard.presentation.PresentationWizardContext.setDesigner(oracle.dss.addins.designer.BIDesigner)
PresentationWizardContext.java:149
boolean oracle.dss.addins.wizard.presentation.PresentationWizardAddin.invokeFromMenu(oracle.ide.addin.Context, java.lang.String[], oracle.dss.addins.designer.BIFolder, oracle.dss.addins.designer.BIDesigner, boolean)
PresentationWizardAddin.java:64
void oracle.dss.addins.designer.BIDesignerAddin.actionPerformed(java.awt.event.ActionEvent)
BIDesignerAddin.java:572
void javax.swing.AbstractButton.fireActionPerformed(java.awt.event.ActionEvent)
AbstractButton.java:1450
void javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(java.awt.event.ActionEvent)
AbstractButton.java:1504
void javax.swing.DefaultButtonModel.fireActionPerformed(java.awt.event.ActionEvent)
DefaultButtonModel.java:378
void javax.swing.DefaultButtonModel.setPressed(boolean)
DefaultButtonModel.java:250
void javax.swing.AbstractButton.doClick(int)
AbstractButton.java:279
void javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseReleased(java.awt.event.MouseEvent)
BasicMenuItemUI.java:886
void java.awt.Component.processMouseEvent(java.awt.event.MouseEvent)
Component.java:3715
void java.awt.Component.processEvent(java.awt.AWTEvent)
Component.java:3544
void java.awt.Container.processEvent(java.awt.AWTEvent)
Container.java:1164
void java.awt.Component.dispatchEventImpl(java.awt.AWTEvent)
Component.java:2593
void java.awt.Container.dispatchEventImpl(java.awt.AWTEvent)
Container.java:1213
void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
Component.java:2497
void java.awt.LightweightDispatcher.retargetMouseEvent(java.awt.Component, int, java.awt.event.MouseEvent)
Container.java:2451
boolean java.awt.LightweightDispatcher.processMouseEvent(java.awt.event.MouseEvent)
Container.java:2216
boolean java.awt.LightweightDispatcher.dispatchEvent(java.awt.AWTEvent)
Container.java:2125
void java.awt.Container.dispatchEventImpl(java.awt.AWTEvent)
Container.java:1200
void java.awt.Window.dispatchEventImpl(java.awt.AWTEvent)
Window.java:922
void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
Component.java:2497
void java.awt.EventQueue.dispatchEvent(java.awt.AWTEvent)
EventQueue.java:339
boolean java.awt.EventDispatchThread.pumpOneEventForHierarchy(java.awt.Component)
EventDispatchThread.java:131
void java.awt.EventDispatchThread.pumpEventsForHierarchy(java.awt.Conditional, java.awt.Component)
EventDispatchThread.java:98
void java.awt.EventDispatchThread.pumpEvents(java.awt.Conditional)
EventDispatchThread.java:93
void java.awt.EventDispatchThread.run()
EventDispatchThread.java:85
Regards,
Scott. -
MAX: how to create a Calculated Channel based on two physical channels?
Good morning,
I need to configure some tasks in MAX with Virtual Channels that are calculations based on physical channels. I saw this article : http://digital.ni.com/public.nsf/allkb/1BFCE6FAD5B3944986256D67006DF7EC but cannot see the equivalent in the newest versions of MAX (V5.1).
As an example I am already acquiring the physical channels Ch1 and Ch2 and I want to build a virtual channel Ch3=E+(A.Ch1+B)/(C.Ch2+D). A,B,C,D,E are constant values. I would then like to integrate Ch3 in a task together with other physical channels that I am acquiring.
Could you direct me to this function?
Thanks for your answer.
ChristopheHello Christophe,
With the newer versions of NI DAQmx and NI MAX there was a choice made to go from the relatively limited VI Logger options to a more extensive form of configurable applications.
For this purpose (and others) NI Signal Express was created, which allows you to configure applications with a limited amount of programming.
To do similar (and more things) then you were used to do with VI Logger you can use NI SignalExpress
http://www.ni.com/white-paper/5825/en/
http://www.ni.com/white-paper/5827/en/
This specific VI logger functionality for the creation of ""virtual channels" (step 5 to 10) through VI Logger Tasks (directly from inside NI MAX) however does no longer exist.
This also more clearly seperates your Configuration Tools (like NI MAX) from your actual applications made with LabVIEW or SignalExpress.
Would using NI SignalExpress be an option for you?
Kind Regards,
Thierry C - Applications Engineering Specialist Northern European Region - National Instruments
CLD, CTA
If someone helped you, let them know. Mark as solved and/or give a kudo. -
How to create a calculated column in sharepoint
I created the custom list in share point. In that list i renamed the title as
Name.
I created the WindowsID as person or group column in share point list.
In the same list, I want to create a new calculated column as EmpName as hyperlink with the below formula
="<a href='"&WindowsID &"'>"&Name&"</a>"
But I am unable to create a new column by using above formula.
Could you please let me know what i missed in the above formula.
Please note that i am unable to see the WindowsID in the insert column.
Thanks for ur support.Hello
Sorry for the delay replay.
Based on your guidance,i followed the below steps
1.created the loginname column of type person or group
2.Added the contentquery webpart
3.crated the custom xslt template
4.Please find the below template
<xsl:template name="ListingItem" match="Row[@Style='ListingItem']" mode="itemstyle">
<xsl:variable name="DisplayTitle">
<xsl:call-template name="OuterTemplate.GetTitle">
<xsl:with-param name="Title" select="@Title"/>
<xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="LoginID">
<xsl:value-of select="ddwrt:UserLookup(string(@DomainID) ,'User')" />
</xsl:variable>
<div id="membersdiv" class="members">
<!-- <xsl:value-of select="$LoginID" disable-output-escaping="yes"/>-->
<xsl:if test="$LoginID != ''">
<a href="{$LoginID}">
<xsl:value-of select="@Title" disable-output-escaping="yes"/>
</a>
</script>
</xsl:if>
</div>
</xsl:template>
if user is having the login id then i need display the title.on click of that title i need to redirect to user settings page like http://url/_layouts/15/userdisp.aspx?ID=1 .How can i redirect to
the sharepoint personal settings page based on person click -
Help needed in creating a calculated keyfigure/query exit
Hi Reporting Gurus
Please someone give me a solution for my issue.
I have two keyfigures
Plan Finish Date(PFD)
Actual Finish Date(AFD)
I have one calculated keyfigure
Delivery Status = (AFD<=PFD) . When this condition is met it returns 1 else 0.
But Delivery Status = (AFD<=PFD) returns 1 if AFD and PFD both exists and if the condition is met and also works (returns 1) for the scenarios mentioned below.
1. if AFD is blank and PFD is filled
2. if AFD and PFD both is blank.
So I need a solution for my issue in such a way that
Delivery Status = (AFD<=PFD) should return 1 only if AFD and PFD both exists and only if AFD<=PFD.
For rest of all the scenarios my calculated keyfigure should return 0 , i.e.,
1.if AFD is blank and PFD is filled
2.if AFD and PFD both is blank.
3.if AFD is filled and PFD is blank.
How to achieve this?
Should I have to write a customer exit variable and incorporate ABAP codes or should I have to write VB macros or can we have a calculated keyfigure with a necessary logic or is there any other way to achieve it.
Please help me out.
Thanks in Advance,
Have a nice day
Regards
SamYou can create a new calculated key figure which calculates the result which looks as follows...
= ((AFD<>0) AND (PFD<>0) AND (AFD<=PFD)) * 1 + 0
Please check the syntax when done. You can refer to the below link for more info abt using IF ELSE operations in calculated keyfigures. Please let me know if you come across any issues.
http://help.sap.com/saphelp_nw04/helpdata/en/23/17f13a2f160f28e10000000a114084/content.htm -
Create a Calculated field in Powershell that has embedded double quotes
Hi
I have a requirement that I am not quite sure is even possible in the context of Site Column
I am getting an error - maybe though lack of embedded quotes but also I am wondering if this should be possible since Created is an OOTB column even if it is not currently used yet.
$formula = 'TEXT(Created,mmYYYY)'
$calcualtedField = $web.Fields.Add($siteColumn.DisplayName , "Calculated" , $false)
$spField.Formula = $formula
$spFeld.Update()
Does this look correct or not
Freelance consultanthi Devendra
Thanks for the reply. In my case I want to set of Site Columns to be provisioned so that I can later pick these to be added to my Content Types. I drive this entirely though .csv files and PowerShell. Hence, I am working at the Site Collection
level :
$calcualtedField = $web.Fields.Add($siteColumn.DisplayName , "Calculated" , $false)
Your code is does a similar thing to what I want but you are building a list with user defined fields.
I will log on the SharePoint server a bit later but do you see this code being valid ... "Created" is the display name for the OOTB Site Column and I have tired to embed quotes for the date mask. This Calc column should be populated when
the site column is added to Content Type which subsequently added to a list or library
$formula = 'TEXT(Created,"mmYYYY")'
Keep going with the YouTube videos as these are really useful
Daniel
Freelance consultant -
Trying to create a calculation but it won't work...
Hi!
I'm using Adobe Acrobat 8.1 for Mac.
I've created a form and I need to enter what I assume to be a custom calculation script.
The field named Text49 needs to be the result of the field named Text46 (manually entered value) multiplied by .062
This is what I've entered in the custom calculation box in Text49:
var v1 = 1 * this.getField("Text46").value;
event.value = v1 * .062;
But it's not working correctly. It'll work the first time when I manually enter a value in Text46 however when I change the manually entered value in Text46, the result in Text49 doesn't change.
Also, Text49 doesn't show up in the box for setting calculation order.
I'm sure it's something with my formula but I can't figure it out and don't know where to look.
Can someone please help?
Thank you so much!
DianeI must have messed something up because now it's not working at all. :(
In response to your question, no there's no script on Text50 but there is custom validation on both Text49 and Text50.
The validation script for Text49 is:
var f = this.getField("Text49");
f.hidden = (event.value < .0000001);
The validation script for Text50 is:
var f = this.getField("Text50");
f.hidden = (event.value < .0000001);
I've tried it with and without the validation script and it's not working either way.
I've tried it with Text49 and Text50 as "hidden" and "visible" and it's not working either way.
The one constant I'm finding is that even when I do get the calculations to work, when I save and close the form and re-open it the calculations have quit working.
I'm at a loss... :(
Any ideas?
Thank you!
Diane
Maybe you are looking for
-
Bookmarks in an exported pdf do not work
I am writing a teacher guide in support of an activity using iBooks Author. I know that many of the users of this document will not have iPads/Macs, so I also want to export the document as a pdf. Within the document, I have several bookmarks, pointi
-
Recurring bootup issues on Macbook Pro
I have a 2012 Macbook Pro running OS X (10.7.5) The last two mornings it has failed to boot. I managed to boot it into recovery mode both times and run a disk repair. After that, it booted up fine, both times. However, it concerns me that this is a
-
How to set up tc as just a back up and disable wireless
i want to set up a used TC as just a back up and keep my new netgear wireless router. How do I set it up? thanks. p.s. new to mac
-
Error handling for importing a file
Hi, I have only been doing java for 1 semester, and have got terribly stuck on my final assg. I have to import a txt file, and catch any exceptions. I know I am not using the correct method to read the file, but am not sure what the alternatives are.
-
My x201 has a maximum screen resolution in the settings of 1280 x 800 but states that anything under 1280 x 960 may mean that some information is not displayed on the screen. I have this problem with a program that I am running. Any suggestions pleas