Help with Java covert 5 loyalty points into 1 credit code.

Can u please provide the code so that:
Loyalty points can be converted into credits (5 loyalty points = 1 credit)
so far i have done....
public void ConvertPoints (int cr, int loy)
erm, these are my fields in the class
public class Loyalty
     private static int currentId = 2000;
private int cardId;
private String name;
private int rating;
private int credits;
private String centre;
public int loyalty;
my constructor:
public Loyalty (String nam, int rat, int cred,String cen, int loyalty)
name = nam;
rating = rat;
credits = 30;
cardId = currentId++;
centre = cen;
loyalty = 20;
Can u pleaseeeeee provide me the code to:
Loyalty points can be converted into credits (5 loyalty points = 1 credit)
thxsss help appreciated x

public class foo {
  private int loyalty, credit;
  public foo() {}
  public int convertLoyaltyToCredits() {
    int credits = loyalty / 5;
    credit += credits;
    loyalty -= 5 * credit;
    return credit;

Similar Messages

  • Help with java mapping

    PI File adapter has a processing option u2018Empty-Message Handlingu2019 to ignore or Write Empty Files. In case there is no data created after mapping on target side then this option determines whether to write an empty file or not. But there is a catch to this option when it comes to using it with File Content Conversion which is described in SAP Note u2018821267u2019. It states following:
    I configure the receiver channel with File content conversion mode and I set the 'Empty Message Handling' option to ignore. Input payload to the receiver channel is generated out of mapping and it does not have any record sets. However, this payload has a root element. Why does file receiver create empty output file with zero byte size in the target directory?  Example of such a payload generated from mapping is as follows:                                                           
    <?xml version="1.0" encoding="UTF-8"?>                          
    <ns1:test xmlns:ns1="http://abcd.com/ab"></ns1:test>
    solution :
    If the message payload is empty (i.e., zero bytes in size), then File adapter's empty message handling feature does NOT write files into the target directory. On the other hand, if the payload is a valid XML document (as shown in example) that is generated from mapping with just a root element in it, the File Adapter does not treat it as an empty message and accordingly it writes to the target directory. To achieve your objective of not writing files (that have just a single root element) into the target directory, following could be done:
    Using a Java or ABAP Mapping in order to restrict the creation of node itself during mapping. (This cannot be achieved via Message Mapping)
    Using standard adapter modules to do content conversion first and then write file. 
    can someone help with java mapping that can be used in this case?

    Hi,
        You have not mentioned the version of PI you are working in. In case you are working with PI 7.1 or above then here is the java mapping code you need to add after message mapping in the same interface mapping
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.Map;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    import org.w3c.dom.Document;
    import com.sap.aii.mapping.api.AbstractTransformation;
    import com.sap.aii.mapping.api.StreamTransformationException;
    import com.sap.aii.mapping.api.TransformationInput;
    import com.sap.aii.mapping.api.TransformationOutput;
    public class RemoveRootNode extends AbstractTransformation{
         public void execute(InputStream in, OutputStream out)
         throws StreamTransformationException {
    // TODO Auto-generated method stub
    try
         DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
         DocumentBuilder builderel=factory.newDocumentBuilder();
         /*input document in form of XML*/
         Document docIn=builderel.parse(in);
         /*document after parsing*/
         Document docOut=builderel.newDocument();
         TransformerFactory tf=TransformerFactory.newInstance();
         Transformer transform=tf.newTransformer();
         if(docIn.getDocumentElement().hasChildNodes())
              docOut.appendChild(docOut.importNode(docIn.getDocumentElement(),true));
              transform.transform(new DOMSource(docOut), new StreamResult(out));
         else
              out.write(null);
    catch(Exception e)
    public void setParameter(Map arg0) {
    // TODO Auto-generated method stub
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    try{
         RemoveRootNode genFormat=new RemoveRootNode();
         FileInputStream in=new FileInputStream("C:\\apps\\sdn\\rootNode.xml");
         FileOutputStream out=new FileOutputStream("C:\\apps\\sdn\\rootNode1.xml");
         genFormat.execute(in,out);
         catch(Exception e)
         e.printStackTrace();
    public void transform(TransformationInput arg0, TransformationOutput arg1)
              throws StreamTransformationException {
         // TODO Auto-generated method stub
         this.execute(arg0.getInputPayload().getInputStream(), arg1.getOutputPayload().getOutputStream());
    In case you are working in PI 7.0 you can use this code
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.Map;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    import org.w3c.dom.Document;
    import com.sap.aii.mapping.api.StreamTransformation;
    import com.sap.aii.mapping.api.StreamTransformationException;
    public class RemoveRootNode implements StreamTransformation{
         public void execute(InputStream in, OutputStream out)
         throws StreamTransformationException {
    // TODO Auto-generated method stub
    try
         DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
         DocumentBuilder builderel=factory.newDocumentBuilder();
         /*input document in form of XML*/
         Document docIn=builderel.parse(in);
         /*document after parsing*/
         Document docOut=builderel.newDocument();
         TransformerFactory tf=TransformerFactory.newInstance();
         Transformer transform=tf.newTransformer();
         if(docIn.getDocumentElement().hasChildNodes())
              docOut.appendChild(docOut.importNode(docIn.getDocumentElement(),true));
              transform.transform(new DOMSource(docOut), new StreamResult(out));
         else
              out.write(null);
    catch(Exception e)
    public void setParameter(Map arg0) {
    // TODO Auto-generated method stub
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    try{
         RemoveRootNode genFormat=new RemoveRootNode();
         FileInputStream in=new FileInputStream("C:\\apps\\sdn\\rootNode.xml");
         FileOutputStream out=new FileOutputStream("C:\\apps\\sdn\\rootNode1.xml");
         genFormat.execute(in,out);
         catch(Exception e)
         e.printStackTrace();
    The code for PI 7.0 should also work for PI 7.1 provided you use the right jar files for compilation, but vice-versa is not true.
    Could you please let us know if this code was useful to you or not?
    Regards
    Anupam
    Edited by: anupamsap on Dec 15, 2011 9:43 AM

  • Help with a flash html inserting into DW

    Hello,
    I have created a enquiry section in flash for one of my html DW pages for my site. When I publish the flash doc ti creates a html page (Contact.html). When I open the flash html page in DW or upload it to my server, everything works fine. I recieve an email at my prefered destination etc etc. But as its only a section of my contact page of my website i need to insert it into my site page (get_in_touch.html) soon as i try and take all the stuff from contact.html and insert it into a div in my get_in_touch.html it doesn't respond when the submit button is pressed..... Can someone please help!!!!!
    Dan

    Thanks for all your help. I've managed to sort out the problem, still not
    sure what it was.... My sites live now.
    Just one question for you if you dont mind.
    The page which has the flash on it (yes this one again!) Well if someone
    goes to the page with out having flash player installed on their machine,
    i'm looking for some script to detect that there computer doesn't have
    Flash and redirect them to another html page I've created.
    Would really appreciated any advice you may have.
    many thanks,
    Dan
                                                                                    pziecina                                                 
                 <[email protected]>                                                                               
    To
                 09/09/2009 16:40                Daniel Herrington        
                                                 <[email protected]
                                                 m>                       
                    Please respond to                                       cc
                 clearspace-571537347-50                                  
                 [email protected]                               Subject
                      ums.adobe.com              Help with a
                                                 flash html inserting into DW
                                                                                    Hi
    Somewhere above your tag, you will have a line similar to this - Also in your tag the swf file -
    These are the files that I said may be wrong or missing.
    However if you just edit the flash generated page and include the items you
    require in this, and maintain the same file position, you should have no
    problems,
    PZ

  • How. Can I get help with illegal iTunes charges on my credit card,for things I did not order. Chuck

    How can I get help with illegal iTunes charges on my credit card for things I did not order. chuck

    Same answer as last times you asked the same question:
    iTunes adding charges to my credit card fog things I did not order. What can I do about it. Chuck

  • Hello  I need your help with installing the flash drive into my laptop

    Hi
    I am Rachel Friedman asking for your help with installing the flashdrive player into my laptop.
    Thanks
    Rachel

    To give you any useful advice, I'm going to need to know more about your computer and browser:
    https://forums.adobe.com/message/5249945#5249945

  • Help with updates - The software change returned error code 0x87D00215(-2016411115).

    I have rolled out bunch of updates across few hundred workstation systems.
    Few of the desktops have failed to install SOME of the updates and just can't get my head around as to why?
    Looking at one of the workstations, I can see 5 updates are pending download at 0%.
    Some of these fail after a while and with in Software Centre, I can see 'Help with updates - The software change returned error code 0x87D00215(-2016411115).'. Not exactly sure what this means, but I have tried clearing the cache and
    rebooting the workstations few times.
    (I have also tried to use Windows Update and install one of these manually, which worked.)

    Investigating this further, I have found the following in CAS.log:
    ICcmContentTransferManager::ModifyJobPriority failed with error 0x87d00215 ContentAccess 01/06/2013 17:19:24 3316 (0x0CF4)
    No need to change timeout settings ContentAccess 01/06/2013 17:19:24 3316 (0x0CF4)
    Successfully created download request {ED6E9E5C-E806-43CA-9F93-49AC72D1DEAD} for content 53bf87a2-bedf-4def-b0ec-9637613c3429.1 ContentAccess 01/06/2013 17:19:24 3316 (0x0CF4)
    Requesting locations synchronously for content 99ddb078-b780-4605-8fac-9607fe56450d.1 with priority Foreground ContentAccess 01/06/2013 17:19:24 3316 (0x0CF4)
    The number of discovered DPs(including Branch DP and Multicast) is 1 ContentAccess 01/06/2013 17:19:24 3316 (0x0CF4)
    Calling back with the following distribution points ContentAccess 01/06/2013 17:19:24 3316 (0x0CF4)
    Distribution Point='http://DPSERVER.com/SMS_DP_SMSPKG$/99ddb078-b780-4605-8fac-9607fe56450d', Locality='LOCAL' ContentAccess 01/06/2013 17:19:24 3316 (0x0CF4)
    Requesting content 99ddb078-b780-4605-8fac-9607fe56450d.1, size(KB) 0, under context System with priority Foreground ContentAccess 01/06/2013 17:19:24 3316 (0x0CF4)
    ICcmContentTransferManager::ModifyJobPriority failed with error 0x87d00215 ContentAccess 01/06/2013 17:19:24 3316 (0x0CF4)
    No need to change timeout settings ContentAccess 01/06/2013 17:19:24 3316 (0x0CF4)
    Successfully created download request {67B7E59B-A386-4EA8-BF39-2EB64B108A6C} for content 99ddb078-b780-4605-8fac-9607fe56450d.1 ContentAccess 01/06/2013 17:19:24 3316 (0x0CF4)
    Requesting locations synchronously for content 61d33de7-9582-41e3-82fc-3e0f970b60f3.1 with priority Foreground ContentAccess 01/06/2013 17:19:24 3316 (0x0CF4)
    The number of discovered DPs(including Branch DP and Multicast) is 1 ContentAccess 01/06/2013 17:19:24 3316 (0x0CF4)
    Calling back with the following distribution points ContentAccess 01/06/2013 17:19:24 3316 (0x0CF4)
    Distribution Point='http://DPSERVER.com/SMS_DP_SMSPKG$/61d33de7-9582-41e3-82fc-3e0f970b60f3', Locality='LOCAL' ContentAccess 01/06/2013 17:19:24 3316 (0x0CF4)
    Requesting content 61d33de7-9582-41e3-82fc-3e0f970b60f3.1, size(KB) 0, under context System with priority Foreground ContentAccess 01/06/2013 17:19:24 3316 (0x0CF4)
    ICcmContentTransferManager::ModifyJobPriority failed with error 0x87d00215 ContentAccess 01/06/2013 17:19:24 3316 (0x0CF4)
    No need to change timeout settings ContentAccess 01/06/2013 17:19:24 3316 (0x0CF4)
    Successfully created download request {12E48136-B545-4C42-9745-9FF97CE38D52} for content 61d33de7-9582-41e3-82fc-3e0f970b60f3.1 ContentAccess 01/06/2013 17:19:24 3316 (0x0CF4)

  • Help with Java Web Service

    Hi,
    I tried integrating java code with java embedding acitivity, but in em it is failing. Can anybody know how to convert the below java code to a webservice, so that I can pass the input paramaters directly to that webservice. I tried of converting java code to webservice in jdeveloper, but because of static void main it is not converting. Can somebody help me in this issue.
    this is the original executable java code.
    package com.holx.api.test;
    import java.util.HashMap;
    import com.agile.api.APIException;
    import com.agile.api.AgileSessionFactory;
    import com.agile.api.IAdmin;
    import com.agile.api.IAgileClass;
    import com.agile.api.IAgileList;
    import com.agile.api.IAgileSession;
    import com.agile.api.IAutoNumber;
    import com.agile.api.IDataObject;
    import com.agile.api.INode;
    import com.agile.api.IProperty;
    import com.agile.api.IServiceRequest;
    import com.agile.api.PropertyConstants;
    import com.agile.api.ServiceRequestConstants;
    import com.agile.px.ActionResult;
    import java.net.URL;
    public class TestAgileAPI {
    //     @Override
    //     public ActionResult doAction(IAgileSession arg0, INode arg1,
    //               IDataObject arg2) {
              // TODO Auto-generated method stub
    //          return null;
         * @param args
         public static void main(String[] args) {
              IAgileSession m_session = null;
              IAdmin admin = null;
              IAgileClass cls = null;
         String sr="PR-KB00028";
    String userName="*******";
    String password="*******";
    String URL="*********";
              try {
                   HashMap params = new HashMap();
                   params.put(AgileSessionFactory.USERNAME, userName);
                   params.put(AgileSessionFactory.PASSWORD, password);
                   AgileSessionFactory instance = AgileSessionFactory.getInstance(URL);     
                   m_session = instance.createSession(params);     
                   admin = m_session.getAdminInstance();
                   cls = admin.getAgileClass( "ProblemReport" );
                   IServiceRequest psr = (IServiceRequest)m_session.createObject( "ProblemReport", sr);
              psr.setValue(ServiceRequestConstants.ATT_COVER_PAGE_DESCRIPTION, "KB-Test-20121400");
              } catch (APIException e) {
                   e.printStackTrace();
              } finally {
                   m_session.close();
    Can somebody help me in converting this code into a webservice which accepts String SR as input from soa.
    Thanks,

    Hi Francois,
    I never tried to use a webservice in the value help wizzard, so I don't know if it works or not.
    But for your problem you can build your own value help to avoid the problem.
    You told us that the webservice works in the storyboard. The value help wizard "only" creates a popup iView in your model and assigns the output field of the popup to an input field in a form.
    Maybe as a solution you can insert a popup to the model by yourself. Assign the output field of your popup to the input field for which you want to have the value help. Inside the popup iView you can use your custom built webservice.
    I know that this is a little bit circuitous, but I think it will work.
    Regards
    Christophe

  • Hi I have a geometry problem.Can anyone help with java code

    Hi I have a non simple polygon . My job is to make it a simple. for that First I need to find the intersecting lines say line AB intersects line CD. If so then I must replace AB & CD with AC & BD or AD or BC which ever keeps the polygon closed . So can anyone help me out with this code
    import java.io.*;
    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.image.*;
    import javax.swing.*;
    public class Simple{
    static int POINTWID = 4; // size of points
    // the x and y arrays hold the coordinates
    // the B array is the order of the points in the polygon
    // You want to fill the C array with the simple polygon
    static double x[] = new double[200];
    static double y[] = new double[200];
    static int B[] = new int[200]; // the permutation matrix
    static int C[] = new int[200]; // the one that becomes simple
    static SimpleFrame myFrame;
    static int numPoints = 3;
    public static void main(String args[]) {
    makePolygons();
    // Create the frame to draw on
    myFrame = new SimpleFrame();
    myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    myFrame.setSize(600, 600);
    myFrame.setVisible(true);
    public static void makePolygons(){
    // Build an array of random points in the unit square
    for(int i = 0; i < numPoints; i++){
    x[i] = Math.random();
    y[i] = Math.random();// Sample program
    B[i] = i; // default permutation
    // Create the simple polygon
    createSimplePolygon();
    * This is the only function you need to mess with
    public static void createSimplePolygon(){
    // Initialize the C[] array with the identity permutation
    for(int i = 0; i < numPoints; i++)
    C[i] = i;
    // Bubble sort the points from left to right
    for(int i = 0; i < numPoints; i++)
    for(int j = 0; j < numPoints - 1; j++)
    if(x[C[j]] > x[C[j+1]]){
    int temp = C[j];
    C[j] = C[j+1];
    C[j+1] = temp;
    public static class SimpleFrame extends JFrame{
    public static JSlider numPointsSlider;
    public SimpleFrame()
    super("Create you own Simple Polygon");
    Container content = getContentPane();
    content.setLayout(new java.awt.BorderLayout());
    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.setPreferredSize (new java.awt.Dimension(300, 400));
    tabbedPane.addTab("Scrambled", new ScrambledPanel());
    tabbedPane.addTab("Simple", new SimplePanel());
    content.add(tabbedPane, java.awt.BorderLayout.CENTER);
    // Slider for the number of points
    numPointsSlider = new JSlider (javax.swing.SwingConstants.HORIZONTAL,
    3, 100, 11);
    numPointsSlider.addChangeListener (new javax.swing.event.ChangeListener () {
    public void stateChanged (javax.swing.event.ChangeEvent evt) {
    numPointsSliderStateChanged (evt);
    content.add(numPointsSlider, java.awt.BorderLayout.SOUTH);
    private void numPointsSliderStateChanged (javax.swing.event.ChangeEvent evt) {
    numPoints = numPointsSlider.getValue();
    makePolygons();
    repaint();
    public static class ScrambledPanel extends JPanel{           
    public void paintComponent(Graphics g){
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;
    // First set the scaling to fit the window
    Dimension size = getSize();
    int Xwid = (int) (0.95 * size.width);
    int Ywid = (int) (0.95 * size.height);
    // First draw the segments
    g2.setColor(Color.red);
    for(int i = 0; i < numPoints; i++)
    g2.drawLine((int) (Xwid * x[B[i]]),
    (int) (Ywid * y[B[i]]),
    (int) (Xwid * x[B[(i+1) % numPoints]]),
    (int)(Ywid * y[B[(i+1) % numPoints]]));
    // Now draw the points
    for(int i = 0; i < numPoints; i++){
    g2.fillRect((int) (Xwid * x) - POINTWID,
    (int) (Ywid * y[i]) - POINTWID,
    2*POINTWID + 1, 2*POINTWID + 1);
    public static class SimplePanel extends JPanel{
    public void paintComponent(Graphics g){
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;
    // First set the scaling to fit the window
    Dimension size = getSize();
    int Xwid = (int) (0.95 * size.width);
    int Ywid = (int) (0.95 * size.height);
    // First draw the segments
    g2.setColor(Color.red);
    for(int i = 0; i < numPoints; i++)
    g2.drawLine((int) (Xwid * x[C[i]]),
    (int) (Ywid * y[C[i]]),
    (int) (Xwid * x[C[(i+1) % numPoints]]),
    (int)(Ywid * y[C[(i+1) % numPoints]]));
    // Now draw the points
    for(int i = 0; i < numPoints; i++){
    g2.fillRect((int) (Xwid * x[i]) - POINTWID,
    (int) (Ywid * y[i]) - POINTWID,
    2*POINTWID + 1, 2*POINTWID + 1);

    Hi I am sorry I could explain you properly . Ok
    My program gives me a polygon(as you can see when u
    run this program)But the polygon is a non simple
    polygon.So to make this polygon we must remove all
    the crossings betweeen edges in the polygon.The
    algorithm which i gave will remove all the crossings
    and make the polygon simple.You did not give an algorithm!
    SO my job is to take the
    existing code and implement the algorithm for this
    program in the Createsimpelpolygon() function. For
    this First the program must find whether two edges
    cross if they cross then swap the vertices like
    replace AB & CD with AC & BD or AD & BC.Which ever
    keeps the polygon closed . Still not entirely clear to me. You cannot just go and replace vertexes from a polygon: that way you'll end up with a different polygon.
    So as we go on we find the
    many crossings and iterate the algorithm on all the
    crossings until we get simple polygon.Like I said: I don't really understand what it is you're after. You did not respond to my suggestions, so I gather it is not what you're after?
    What about Polygon Tessellation (Google for it)? Perhaps that's what you want.
    Also, why do you not create a (or use java.awt's) Point class and a Polygon class which holds a java.util.Set of Point's? Your current code looks rather messy.

  • Need help with java will even pay

    I need extreme help. I just don't have time lately to write these programs and I have fallen extremely behind. Basically all I need is to pass this class and right now until I can get some more help I just can't make the deadlines. If someone could help me I will pay you just like a tutor.
    Requirements for Lab.
    You will need to develop a variety of classes for this lab. Specifically, you need to create:
    +1. a "PersonGUI" class that displays fields for a person's: firstName, lastName, identificationNum, and sex.+
    +2. a "StudentGUI" class that provides Java components for the entry of: classification (freshman, sophomore, junior, senior, or graduate student), and Checkboxes for (a student being in the Honor's program and/or in the ROTC).+
    +3. a "FacultyGUI" class that provides Java components for the entry of: rank (instructor, assistant, associate, or full professor), years of service, and salary.+
    +4. a "Statistics" class that, when instantiated, creates an object containing an instance variable for each of the the statistical values outlined below. (Each of these instance variables should be declared to be "private".)+
    Your main Lab6 class should provide a means for the user to:
    +1. Specify the kind of personal data to be entered (Student or Faculty), and+
    +2. Then, depending on the choice made, appropriate fields should be displayed to allow the user to input appropriate information for the type of personal data being entered, and+
    +3. Controls that support the following functionality:+
    * a "CANCEL" control that will terminate any operation currently being performed and return the user to the "Startup" window.
    * a "SAVE" control that will cause the just entered data to be harvested from the graphical user interface and the appropriate statistics to be updated. Note: this function may NOT be performed if any of the student or faculty member data fields have not been filled in.
    * a "RESET" control that will erase all information recorded to date (i.e., all summary variables are reset to zero).
    * a "CLEAR" control that will erase all fields for the personal data currently being entered.
    * and a "DISPLAY TOTALS" control that will display, when pressed, the following data:
    +1. For students:+
    +1. total number of students entered so far,+
    +2. number who are male and number who are female,+
    +3. number of freshmen, sophomores, juniors, seniors, and graduate students,+
    +4. number of students who are in the Honor's program and number who are in the ROTC.+
    +2. For faculty:+
    +1. total number of faculty entered so far,+
    +2. number who are male and number who are female,+
    +3. the name and salary of the highest paid faculty member on campus.+
    Your program should validate numeric data to the extent:
    +1. no numeric field (id number, years of service, or salary) may be left blank by the user. If done so, the user should be alerted to enter a numeric value.+
    +2. when the user enters a "years of service" value for a faculty member - the value entered should be verified to be a valid integer value in the range 1 to 50. If the data entered is outside the valid range or is not a valid integer - your program should reject the value and prompt the user that invalid data has been entered and that a new value is necessary.+
    +3. when a faculty salary is entered, verify that it is a floating-point value in the range $35,000 to $200,000. Handle invalid data as described above.+
    +4. Similarly, if an invalid integer value is entered for the identification number, the value should be rejected and the user prompted to reenter.+
    +5. Information should not be saved, nor should statistical values be updated, until all numeric data has been validated.+
    Note -- You will be graded on appropriate use of instance vs. local variables, use of methods, and passing parameters and returning appropriate values.
    +1. The 'Statistics" class MUST provide "mutator" and "accessor" methods that are required to access values or to modify the values of any variable. REMEMBER ALL VARIABLES ARE DECLARED TO BE "private"!!+
    +2. You should implement methods to verify the data, as detailed above. The methods should return boolean values indicating whether the data is acceptable or not.+

    Sorry to hear about your problems - lack of time, having fallen behind, imminent failure etc - but none of these are Java problems.
    This site deals with Java problems: compiler or runtime behaviour that people can't understand. If you have problems of that sort (and especially if solving those problems would help with the problems you did describe) then post them.
    Otherwise you would seem to be in the wrong place.

  • Help with JAVA StringObject - & assign user input; StringMethod

    Hi Everyone! I need help with this Java Program, I need to write a program, single class, & file. That will prompt the user to enter a word. The output will be separted by hypens and do this until the user enters exit. I think this is done by using a string variable. Then use the length of the word to setup a loop to print each letter out with hypens. (example c-a-t)
    1. I think I should store the word like this: Word.Method(). Not sure of this the API was confusing for me because I wasn't sure of what to do.
    2. A string method to find out how many letters are in the user's word in order to setup a loop to print each letter out. I think I can use a While loop to accomplish this?
    3. A string method to access each letter in a string object individually in order to print individual letters to the screen with those hypens. This is really confusing for me? Can this be accomplished in the While loop? or do I declare variables in the main method.
    Any examples you can refer me to would be greatly appreciated. Thanks

    Getting user input:
    This may look strange to a newbie but there's nothing much you can do since you wanted a single class file:import java.io.*
    public class InputTest {
       public static void main(String[] args) {
          BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
          System.out.println("Hi! Please type a word and press enter.");
          String lineReadFromUser = in.readLine();
          System.out.println("You typed " + lineReadFromUser);
    }You can get the lenght of a String using the length() method. Example: int len = "Foobar".length();
    You can get the individual characters of a String with the charAt() method. Example: char firstCharOfString = string.charAt(0);
    (remember that the argument must be from 0 to length-1)
    You can access the documentation of all classes, including java.lang.String, at http://java.sun.com/j2se/1.3/docs/api/index.html You can also download the docs.

  • Help with Java assignments

    I need some help with some Java assignments. I'm new to it, and I am having some problems.

    People will help you - if you help them first by stating your problem. If it was a generic question wanting to know wether anyone will help you at all - the answer is yes, they would - you have to put your work in first however.
    Ironluca

  • Help with Java Web Start

    Hi everybody,
    I have a simple Java application that has a JFrame containing a TextField displaying some text inside it. I am using the NetBeans IDE. I am trying to Enable Java Web start for this application. The steps I have taken upto now are:
    1. Right click on Project, Java Web Start -> Enable Java Web Start. This created the jnlp file.
    2. In the Resources section, I added the jar file for swing. ( I am not sure if I have to add the path for jnlp.jar etc, or are these found automatically?)
    3. Right click on Project, Java Web Start -> Deploy with Java Web Start. This launches the browser with the Click me link, but on clicking this link, I get the following error.
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: Wrapper cannot find servlet class jnlp.sample.servlet.JnlpDownloadServlet or a class it depends on
         org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
         org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
         org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
         org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
         org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
         org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
         org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
         java.lang.Thread.run(Thread.java:534)
    root cause
    java.lang.ClassNotFoundException: jnlp.sample.servlet.JnlpDownloadServlet
         org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1332)
         org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1181)
         org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
         org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
         org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
         org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
         org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
         org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
         org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
         java.lang.Thread.run(Thread.java:534)I have all the jnlp files in my jdk directory, and I am not sure why it can't find it. Is there something I am missing?
    Thanks
    George

    I am not sure what it has to do with servlets, I just followed a tutorial on using Netbeans with Java Web Start, and did only the steps as mentioned in my first post. And ended up with the error.
    Anyways, I added the jnlp jar files(jnlp.jar, jnlp-servlet.jar, jardiff.jar) in the WEB-INF/lib directory. And it seems to deploying it now. I can get my application to load on clicking on the "Click me" link. But the controls on my application don't seem to be working.
    Also, when I try to Right click on my project -> Java Web Start -> Run with Java Web Start, I get the following error message,
    javaws-run: C:\Documents and Settings\Lux\Visualization\nbproject\build-jaws-impl.xml:36: Execute failed: java.io.IOException: CreateProcess: C:\j2sdk1.4.2_13\bin\javaws "file:///C:/Documents and Settings/Lux/Visualization/Visualization.jnlp" error=2
    BUILD FAILED (total time: 0 seconds)
    Any help appreciated.
    Thanks.
    George

  • Help with java.util.Random

    Problem:
    I wanna generate random number in interval <0;1> with two "decimal number precision" (i dont know, how to expres it exactly in English.. So, here is Patern: "*X.XX*" (For ex. it might be numbers like 0.24 , 1.00 , 0.05, 0.54) ).
    I have tried to work with java.util.Random class, but i dont understood it at all, because i'm not good in Math-English terms.
    So, how can I do it? I offer duke stars for any solve. Thanks.

    First of all, read this link to understand why all floating point numbers (float, double) can't be rounded to two places of decimals.
    [What Every Computer Scientist Should Know About Floating-Point Arithmetic|http://docs.sun.com/source/806-3568/ncg_goldberg.html]
    Consider changing your program to use integer numbers in the range of [0..100] instead. You can generate a random number in this range byRandom random = new Random();
    int randomInt = random.nextInt(101);If your problem can't be solved with this approach, you may need to tell us exactly how you plan to further process the random number.
    luck, db

  • Help with java error

    Hi I got this error and i don't know what it means or how to fix it
    if you understand it please help
    Bad installation. Error invoking java vm(execv)
    C:\program Files\java\ire1.5.0_10\bin\javaw.exe
    I got this error when i went to add and remove programs in winXP
    and highlighted a program called Goban3 and clicked on change\remove
    http://www.gokgs.com/
    goban3 is sign on link to KGS
    if you check the site KGS you can see some java related items that have to be done i use this sights for years without problems
    but now im having problems with java
    thanks for serious reply
    Message was edited by: r
    revest

    That looks alot like this.

  • Help with java digital signing code

    hello people.
    can anybody help me?
    i have find a java code to resolve my problem with sending pay in soap envelope with digital signature and attached certificate. i compiled it with jdk jdk1.6.0_37. and it works.
    i need it to work in built-in jvm in oracle 9i. in oracle 9i jvm release is 1.3.1. Java code does not work there. there is an error
    class import com.sun.org.apache.xerces.internal.impl.dv.util.Base64 not found in import.
    i did not find this class in network.
    can anybody help with rewriting it for jvm 1.3.1?
    thanks in advance.
    code below:
    import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
    import java.io.*;
    import java.security.Key;
    import java.security.KeyStore;
    import java.security.PrivateKey;
    import java.security.Signature;
    import java.security.cert.Certificate;
    public class Sign {
    public static void main(String[] args) throws Exception {
    // TODO code application logic here
    BufferedReader reader = new BufferedReader(new FileReader("c:\\cert.p12"));
    StringBuilder fullText = new StringBuilder();
    String line = reader.readLine();
    while (line != null) {
    fullText.append(line);
    line = reader.readLine();
    KeyStore p12 = KeyStore.getInstance("pkcs12");
    p12.load(new FileInputStream("c:\\cert.p12"), "Hfrtnf$5".toCharArray());
    //????????? ????????? ????, ??? ????? ????? ???????????? alias ? ??????
    //Key key = p12.getKey("my kkb key", "ryba-mech".toCharArray());
    Key key = (Key) p12.getKey("my kkb key", "Hfrtnf$5".toCharArray());
    Certificate userCert = (Certificate) p12.getCertificate("my kkb key");
    String base64Cert = new String(Base64.encode(userCert.getEncoded()));
    //signing
    Signature signer = Signature.getInstance("SHA1withRSA");
    signer.initSign((PrivateKey) key);
    signer.update(fullText.toString().getBytes());
    byte[] digitalSignature = signer.sign();
    String base64sign = new String(Base64.encode(digitalSignature));
    String base64Xml = new String(Base64.encode(fullText.toString().getBytes()));
    System.out.println("<certificate>" + base64Cert+"</certificate>");
    System.out.println("<xmlBody>" + base64Xml+"</xmlBody>");
    System.out.println("<signature>" + base64sign+"</signature>");
    Edited by: user13622283 on 22.01.2013 22:08

    My first search is to see if there is an Apache commons project that provides it. Lo and behold:
    http://commons.apache.org/codec/apidocs/org/apache/commons/codec/binary/Base64.html
    commons-codec.

Maybe you are looking for