Formatting a string and number?

I have a to use the method toString() which calls getPay(). getPay() gives a double value of the employee pay. This is what I have for the toString() method:
abstract class Employee{
private String name;
private double pay;
Employee(String n)
name=n;
public double getPay()
return pay;
public String toString()
double amount = getPay();
return format("Employee Name: %s\n Employee Pay: %.2f",name,amount);
}I have looked all over google and the syntax that I am using seems to be right. I have even tried putting name and amount in an object and eclipse still throws a fit with the format method. Any ideas?

Should I create an object array with the values of
name and amount? And then use that as the argument
for format?I believe the API docs for String, the varargs intro I linked, and trying it for yourself will answer the question.
I'm not trying to be an asshole, really. I'm trying to get you to realize that you can find these kinds of answers on your own. Once you get used to that idea, you'll thank me for it. :-)
Seriously: Read the docs, figure out what you think they mean, write some code based on the assumption that you're right, and see what happens. Repeat. Once you hit a brick wall that way and run out of ideas, post again.

Similar Messages

  • Autoincrement Sequence with String and number

    Hi,
    I have a db for a small company where there are different kinds of employees.
    As a primary key of each table (for each type of employee), I would like to have a combination of a string and integer.
    e.g. if the employee is a car mechanic then the primary key should be something like: CM001, CM002, ....
    if the employee is from the it department then the primary key should be like: IT001, IT002, ....
    I have found a few script for sequences and triggers to use the auto-increment, but I could not find anything about concatenating a string in front of the integer.
    any help appreciated.
    thanks

    user5205421 wrote:
    As a primary key of each table (for each type of employee), I would like to have a combination of a string and integer.You really don't want to have a combined column in your tables, and certainly not as a primary key.
    If you use a combined column you'll find your are uncombining the column all over your application using substr's, index usage will not be trivial anymore, people can't change from departments anymore since primary keys can never change. You are just asking for trouble. When your customer says that that's the number/code they want to see and with which they identify themselves, that doesn't mean you need to implement it as a primary key.
    My advice:
    - create an ID column with a primary key constraint and fill it using a sequence.
    - have a department code column, optionally a foreign key to a table with departments
    - use: department_code || to_char(id,'fm000') or department_code || row_number() over (partition by department_code order by id), only for display reasons in your applications, possibly in a view.
    Regards,
    Rob.

  • Read only number from string and number

    I have "COM4" from my I/O.  how could to read number 4 only?
      Thank you
    Solved!
    Go to Solution.

    Hello, i might need your help regarding this matter.
    I'm current taking a reading from Arduino from 2 accerolmeter to Labview. X=0.02 Y=-0.03 Z=0.99 A=0.33 B=0.42 C=0.84 (Example) 
    But when i display them using Waveform Chart in labview, I need to use the array to count the position of the String from buffer which sometimes might be inaccurate due to the the value extracted.
    I was told that i can use Search string from the beginning to allow the waveform to take in only the numeric. 
    Are you able to assist me regarding this issue?
    Below attached are the pictures..
    Attachments:
    LabviewBlockDiagram.png ‏64 KB
    LabviewFrontPanel.png ‏196 KB

  • Format large string for mysql

    I am reading a large txt file that contains sigle quotes and double quotes... I want to format the string and send it to a blob cell in mysql. I need to add an escaoe character before single quotes and double quotes. Any suggestions?

    john joe wrote:
    I am reading a large txt file that contains sigle quotes and double quotes... I want to format the string and send it to a blob cell in mysql. I need to add an escaoe character before single quotes and double quotes. Any suggestions?
    Yes!  Use "Search and Replace String" with "replace all?" = True.  Replace "'" with "\'" and replace """ with "\"".
    Cheers.
    Message Edited by tbd on 02-12-2007 11:06 PM
    "Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)

  • Formatting a string with time stamp and double precision numbers

    %s\t%f\r%f
    This is a format string that I have in old code that I've decided to change.  Problem is I cannot make sense of the string codes in my own old code! Let me explain what I want, and hopefully someone can explain how to do it.
    I am using the format into string subvi to merge a time stamp (formatted as %m%d%Y%H%M%S%5u) and two different double precision numbers.  This string is then wired into the Write Characters to File subvi so that I can record data as a .txt file, and open it in either Matlab or Excel.  There is a minor problem with the string format above because in excel the first time stamp entry is blank, and the first loop only gives the two double precision numbers withouth the time stamp - the time stamp appears in the next loop (probably a looping issue and not due to the string format, but if you see differently please let me know).  Now what I want to do is 1. potentially fix that problem and 2. add some more doubles. 
    1. Is there a string format issue that is evident that I am not seeing that causes the time stamp to be formatted into the string after a carriage return?  Or should I be looking at looping issues?
    2. How do I add another one - three floating point numbers (double precision)?  Are the \'s marking different numbers in this string constant?  Or is it the %?  I can't find any information about the \'s, but I see that % begins the format specifier. 
    Ideally, I want these data in the following columns:  Date, Time(absolute), FP, FP, FP, carriage return for the next loop (FP is floating point double precision number).
    Thanks,
    Brad

    Hi JonN,
    Here there is no need of string concordinate function (in your code), the same result you can find if you connect the output of the format string to shift register, and shift register in data to initialize string connector in format into string function.
    <<KUDOS ARE WELCOME>>
    ELECTRO SAM
    For God so loved the world that he gave his one and only Son, that whoever believes in him shall not perish but have eternal life.
    - John 3:16

  • Form Letter Report - How To Format Date and Number Hidden Fields

    Hi
    Is it possible to format date and number fields in a form letter report. This case were Paper Design shows fields as $<hire_date>. The examples in reference book only print character values which do not require formatting. I cannot determine how to achieve this. Cannot select fields from Paper Design view as per other report styles where can apply formatting. Do I have to perform formatting in the query to return date as string in format I wish for? This is not case for other report styles.
    Thanks

    you could add a field, set the source of the field to hire_date (assuming hire_date is a column in the data model), and put a format mask of whatever format you want. then set visible to No.
    then instead of &<hire_date> you can instead type &<name of your new field>.

  • Fract/Exp String to Numbe Display Format

    I have a Numeric String which has a large decimal value, with the Digits of precision ranging upto 16 digits. I want to convert this String to a Numeric value and I have used a 'Fract/Exp String to Number'. In my VI I hae set:
    Data Type: EXT (because it allows Number of Decimal Digits from 15 to 20)
    Data Format: Floting Point
    Digits: 16
    Precision Type: Precision Digits
    The following is my question: If the input string has Precision Digits = 15 Eg: 5.369607712106161
    Then I am getting output = 5.3696077121061609, which is about the same, but not the same number I sent.
    or , String 1.145152879691825 gives me number = 1.1451528796918251
    String 5.818356760119754 gives me number = 5.8183567601197543
    Please suggest how I can make the output more precise. 
    Thank you.
    Regards,
    H.
    Solved!
    Go to Solution.
    Attachments:
    FractStringToNumber.vi ‏6 KB

    Hello Darin
    Thank you for the post. It worked!
    I do not understnd one thing: My  output number is EXT and the default value is also EXT with precision value set to 0. How does wiring the default value itself works, while not wiring it didnt work before!
    Thanks,
    H
    Message Edited by H P on 12-17-2009 03:45 PM
    Attachments:
    FractStringToNumber.vi ‏7 KB

  • Little help with EL: concat static string and databound number

    Hi OTN,
    I'm a bit stuck with a simple - as I thought - case: concatenating static string and databound number in EL:
    I have a deffered expression like:
    #{1 != 2 ? ('Number is ' bindings.SomeNumber.inputValue) : 'no number'}
    1 and 2 are databound values too but the question is about showing "Number is 5" where 5 is a SomeNumber.
    Expression editor shows error on 'Number is'. And the error dissapperars if I remove "bindings.SomeNumber.inputValue".
    How can I concatenate them?
    Thanks.

    Another option for you is to write that formatting logic in a static utility classes that takes parameters to return strings.
    Ex.:
    */WEB-INF/utils.tld:*
    <taglib xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd" version="2.1" xmlns="http://java.sun.com/xml/ns/javaee">
      <description>utils</description>
      <display-name>utils</display-name>
      <tlib-version>1.0</tlib-version>
      <short-name>utils</short-name>
      <uri>http://biz.com/utils</uri>
      <function>
         <name>getFormattedNumber</name>
         <function-class>com.mybiz.FormatUtils</function-class>
         <function-signature>java.lang.String getFormattedNumber(oracle.jbo.domain.Number)</function-signature>
      </function>
    </taglib>And then you use them in your EL expression like this:
    page.jspx:_
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:f="http://java.sun.com/jsf/core"
              xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
              xmlns:utils="http://biz.com/utils">
      <af:outputText value="#{utils:getFormattedNumber(bindings.Number.inputValue)}"/>
    </jsp:root>Better to have many options isn't it?

  • Date and number display format

    Hello all,
    I am new to Adobe Form, and I am quite unimpressed with how difficult it is to do the most simple things.
    I have managed one way or another to solve all my problems until now, but this one got me stuck.
    I have date and number fields in my form, and here is what I want to do but cannot:
    - I need these fields to be displayed using the defaults date and number settings of the SAP user who is generating the form. This one is really hard for me to figure out.
    - I need some other fields to be displayed in a specific format depending on a variable in the context of my form. I imagine this could be done using scripting, but how to change the display format of a field via scripting?
    Anyone has an idea of how that can be achieved?
    Thank you.

    Hi Thomas,
    For these kind of issues you will get many answers if you search the forum.
    If your requirement is to display the current date in the form, just drag and drop the "Current date" UI element from the Library palette -> Custom.
    If it is to get the date from SAP and display, pass date to the context node and just drag and drop the field into the form from the data view.
    Check the following wiki by Chintan. It explains some common scenarios in javascript.
    [JavaScript Part 1|http://wiki.sdn.sap.com/wiki/display/ABAP/JavaScriptforCommonScenarios-PartI]
    [JavaScript Part 2|http://wiki.sdn.sap.com/wiki/display/ABAP/JavaScriptforCommonScenarios-PartII]
    Use an 'if' condition, check the value and based on the value you can make the field hide/visible in the form.
    Hope this will help.
    Thanks & Regards,
    Sanoosh

  • A question about date and number formats

    Hi,
    I have to change date and number formats from USA to UK format. Is the only place I must do that in user settings (SU01) ? I mean, is this enough or are there any other customizing settings, in FI for example ?
    Thanks in advance,
    Paulo

    I tested very much and the only place we should set it is on user settings

  • Delimiteddata and number format mask

    Hi,
    I need to export data from my report to a csv format in reports 6i.
    I installed patch 12 so I can use the delimiteddata format.
    This works but I do have problems with the number format.
    I formatted all of the number fields so they appear as desired in the report when running in C/S mode.
    I learned that you can use the number format, date format and cell wrapper variables for delimited and delimiteddata formats.
    These parameters do work with delimited output but they don't when generating delimiteddata.
    Only when I start the reports builder with numberformatmask=something on the command line then the number format given on the command line will be used. but then you cannot change it (even not in the dialog when generating a delimited format) anymore once reports builder is open.
    Is there a solution for this problem or is it fixed in a later patch (I haven't seen anything new in then patch 13 notes).
    Piet

    Hi Pieter,
    This does looks like a Bug. Please contact Oracle Support to assist you in getting the right patch or otherwise.
    Regards
    Oracle Reports Team.

  • Crystal 2011 linking table with a String and a Number

    Hello,
    I am able to retrieve the data I want with the following  SQL Query in SQL: If I try to create it in Crystal 2011 APPLRUNN is a string and CNTBTCH is a number. Is there a way I can link these two fields if one is a string and the other is a number ?
    SELECT   
    ENADV.APPLRUNN, ENPBD.CNTBTCH,
    ENPBD.DOCNBR
    FROM       
    ENADV INNER JOIN
    ENPBD ON ENADV.APPLRUNN = ENPBD.CNTBTCH
    Thanks,
    Debbie

    Hi Debbie,
    You cannot linking  table with a string and a number. I have given a example query:
    SELECT   
    ENADV.APPLRUNN, ENPBD.CNTBTCH,
    ENPBD.DOCNBR
    FROM       
    ENADV INNER JOIN
    ENPBD ON
    ENADV.APPLRUNN = ENPBD.APPLRUNN  or ENADV.CNTBTCH = ENPBD.CNTBTCH
    I modify last sentense because one table primary key is equal to another table Foreign key i.e
    one table ID field = another table ID field or one table NAME field = another table Name field.
    Please understand my intenction and check linking fields in tables.
    Thanks,
    DJ

  • IPhone number formatting for Ireland and the UK now supported!

    I was pretty impressed to discover that the iPhone 2.2 update now supports telephone number formatting in Ireland and the UK.
    So, for example an Irish mobile number will be displayed as (086) XXX XXXX instead of just 086XXXXXXX. Seems to work flawlessly for any number I've tried, including special rate like freephone 1 800 etc.
    The same is now also true for the UK, it displays the numbers correctly formatted now too!
    It certainly makes things easier to read!

    vice versa in us

  • Currency and Number Formats

    Hi Guys
    Is anybody aware of an equivalent of ISO 8601 that deals with Currency and Number formats?
    Thanks

    Thanks John
    My original question was a little ambiguous. What I'm really asking is whether, as with 8601, there is an agreed standard way of expressing numbers, (including currency). For instance, is there an 'approved' sign for indicating the start of the decimal portion, ('.' or ',')?
    The application already makes use of the various formatting utilities and ResourceBundles but I've been asked to investigate if there is an ISO specification that we should default to, (rather than just UK English). As I'm sure anybody who has used their site will appreciate, it is not overly simple to establish the existence and contents of a standard ;->
    Thanks in advance
    J

  • Day of year bug - format date/time string and scan from string?

    I've noticed that the day of year returned by "Format Date/Time String.vi" starts with a value of 1 for Jan-1 while "Scan from String.vi" wants a 0 index.  Is this a bug or feature?  
    (I'm using Labview 2010 Service Pack 1)

    I think the best idea is to use seconds since for your arithmetic, because it is going to be the most consistent and robust solution. Knowing that a day has 86400 seconds is all that is needed and you won't run in possible inconsistencies with date time implementations caused by our anything but logic calender. I would hazard that the functionality of converting a timestamp into year and day of year and back is impossible to make consistent without sacrificing other possibly conflicting transformation in the Timestamp into String and Timestamp from String manipulations.
    "Seconds since" being the actual base unit in all LabVIEW timestamps, it is best to do any arithmetic on it in this base unit.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

Maybe you are looking for

  • Adding a new parameter to the existing report in GL(GLRTR1.rdf)

    Hi Friends, I was new to this oracle Forums and i am working as a oracle apps technical consultant, i have been assigned a task in GL module to customise the existing report in GL the report name is "GLRTR1.rdf" (available in vision-demo) and its con

  • How do i fix 306 error i tunes for mac

    I have a netgear WRN 2000 router and cannot access itunes store error 306

  • Source system field

    Hi all, I am looking for source system field in FCH8 or F-44 transactions. Can any one let me know what would be this field. Thanks Khan

  • Searching Global Documents

    Maybe I'm understanding this wrong... When I read the Help, I had the impression that if I link to an external document on a different server, Robohelp scans that file, making the contents of that file available when I do a search? There's also a not

  • Unable to register PL/SQL test in Diagnostics

    Hi all I try to register a new test in Diagnostics Dashboard with a PL/SQL procedure test template, but Still get error XML File Name: /home/weibxia/Diagnostics/PlsqlDiagnosticTestTemplate.xml Status: Failed Reason: The PL/SQL procedure 'FUSION.FND_D