Java code help needed for If-elseif statement

HI All,
Apologies for posting such a trivial thing but I am a novice in Java.
All I need is to code an If elseIF statement.
I tried the code below
String w = "SAPA";
String x = "SAPB";
if (a==w) ;
{Channel channel = LookupService.getChannel("BS_PROD","CC_RFC_LOOKUP");}
else if (a==x)
{ Channel channel = LookupService.getChannel("BS_PROD","CC_RFC_LOOKUP_ECQ"); }
It came back with the error
Source code has syntax error:  D:/usr/sap/XRD/DVEBMGS02/j2ee/cluster/server0/./temp/classpath_resolver/Map695b77619ad011dd8d0b001a4b52813a/source/com/sap/xi/tf/_MM_TRANSMISSION_CHECK_TO_GENIUS_.java:324: 'else' without 'if' else if (a==x) ^ 1 error
Appreciate if you could let me know the correct code.
Many thanks
Shirin

HI Aamir,
After I removed the semi-colon iIt came back with the following error
Source code has syntax error:  D:/usr/sap/XRD/DVEBMGS02/j2ee/cluster/server0/./temp/classpath_resolver/Map1d9b43e09ad111dd84b7001a4b52813a/source/com/sap/xi/tf/_MM_TRANSMISSION_CHECK_TO_GENIUS_.java:328: cannot resolve symbol symbol : variable channel location: class com.sap.xi.tf._MM_TRANSMISSION_CHECK_TO_GENIUS_ accessor = LookupService.getRfcAccessor(channel); ^ 1 error
Just for reference my entire Jave UDF looks like this:
//write your code here
String w = "SAPA";
String x = "SAPB";
  String content = "";
MappingTrace importanttrace;
importanttrace = container.getTrace() ;
//Filling the string with our RFC-XML (With Values)
String m = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:ZIFMS_GET_NEXT_NUMBER xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\"><I_NR_RANGE_NR>01</I_NR_RANGE_NR><I_OBJECT>ZIFMS_INT</I_OBJECT></ns0:ZIFMS_GET_NEXT_NUMBER>";
RfcAccessor accessor = null;
ByteArrayOutputStream out = null;
try
//1. Determine a channel (Business System, Communication channel)
if (a==w)
{Channel channel = LookupService.getChannel("BS_PROD","CC_RFC_LOOKUP");}
else if (a==x)
{ Channel channel = LookupService.getChannel("BS_PROD","CC_RFC_LOOKUP_ECQ"); }
//2. Get a RFC accesor for a channel.
accessor = LookupService.getRfcAccessor(channel);
//3. Create a xml input stream representing the FM request message.
InputStream inputstream = new ByteArrayInputStream(m.getBytes());
//4. Create xml Payload
XmlPayload payload = LookupService.getXmlPayload(inputstream);
//5. Execute Lookup
Payload result = accessor.call(payload);
InputStream in = result.getContent();
//This are the extra step which i dont know what it mean
//out = new ByteArrayOutputStream(1024);
//byte[] buffer = new byte1024;
//for (int read = in.read(buffer); read > 0; read = in.read(buffer))
//out.write(buffer,0,read);
//content = out.toString();
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(in);
NodeList list = document.getElementsByTagName( "E_NUMBER" );
Node node = list.item(0);
if (node != null)
node = node.getFirstChild();
if (node != null)
content = node.getNodeValue();
} catch (Exception e) {
importanttrace.addWarning("Error while closing accesor" + e.getMessage());
catch (LookupException e)
importanttrace.addWarning("Error While lookup" + e.getMessage());
//This exception is not to be catch at this step as there is no try step before this
//catch (IOException e)
//importanttrace.addWarning("Error" + e.getMessage());
finally
if(out!=null)
try{
out.close();
} catch (IOException e) {
importanttrace.addWarning("Error while closing system" + e.getMessage());
//7. close the accessor in order to free resources
if (accessor!=null) {
try{
accessor.close();
} catch (Exception e) {
importanttrace.addWarning("Error while closing accesor" + e.getMessage());
return content;

Similar Messages

  • Urgent java code help needed

    i need java code for writing following lines in a file
    <?xml version="1.0"?>
    <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
    "http://www.wapforum.org/DTD/wml_1.1.xml">
    Moreover i need code for reading word by word html file.
    PLease reply as soon as possible.
    iwapsms

    for the html-part there are several html-parser, that bould whole parsetrees, which you can traverse (walk) through as you whish. just check google for it (something like: java html parser).
    if that xml you have there is in String-form, just use a Filewriter
    BufferedWriter writer = new BufferedWriter (new FileWriter (new File ("FilePath/filename.xml")));
    writer.write (xmlString);
    writer.close();however, if you have to juggle xml tags, content and attributes a lot, i'd recomend jdom to construct the xml and saxParser to write it.
    again jsut google for it.

  • File missing (file\BCD error code 0Xc0000034 help need for work!

    file missing (file\BCD  error code 0Xc0000034 help need for work!    what can i do?
    have an p 2000 notebook pc

     Hi bobkunkle, welcome to the HP Forums. I understand you cannot boot passed the error you are receiving.
    What is the model or product number of your notebook? What version of Windows is installed?
    Guide to finding your product number
    Which Windows operating system am I running?
    TwoPointOh
    I work on behalf of HP
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos, Thumbs Up" on the bottom to say “Thanks” for helping!

  • Stupid Java Question (Help Needed!!!)

    I have a piece of Java Code that dynamically builds a SQL statement (including VARCHAR2 columns). Oracle gives an error if my string has a single quote in it. I need to replace each single quote with two single quotes in Java, i.e. I need a Java equivalent of PL/SQL REPLACE function.
    Java str.replace only replaces an individual character (see below).
    String l_str = "O'Hara";
    String l_str2 = l_str.replace('\'', '\'');
    I need to replace "O'Hara" with "O''Hara". Any help is appreciated

    Please don't post same question on both forums.
    Please find the answer at:
    Re: ORA-09004

  • Help needed for writing query

    help needed for writing query
    i have the following tables(with data) as mentioned below
    FK*-foregin key (SUBJECTS)
    FK**-foregin key (COMBINATION)
    1)SUBJECTS(table name)     
    SUB_ID(NUMBER) SUB_CODE(VARCHAR2) SUB_NAME (VARCHAR2)
    2           02           Computer Science
    3           03           Physics
    4           04           Chemistry
    5           05           Mathematics
    7           07           Commerce
    8           08           Computer Applications
    9           09           Biology
    2)COMBINATION
    COMB_ID(NUMBER) COMB_NAME(VARCHAR2) SUB_ID1(NUMBER(FK*)) SUB_ID2(NUMBER(FK*)) SUB_ID3(NUMBER(FK*)) SUBJ_ID4(NUMBER(FK*))
    383           S1      9           4           2           3
    384           S2      4           2           5           3
    ---------I actually designed the ABOVE table also like this
    3) a)COMBINATION
    COMB_ID(NUMBER) COMB_NAME(VARCHAR2)
    383           S1
    384           S2
    b)COMBINATION_DET
    COMBDET_ID(NUMBER) COMB_ID(FK**) SUB_ID(FK*)
    1               383          9
    2               383          4
    3               383          2
    4               383          3
    5               384          4
    6               384          2          
    7               384          5
    8               384          3
    Business rule: a combination consists of a maximum of 4 subjects (must contain)
    and the user is less relevant to a COMB_NAME(name of combinations) but user need
    the subjects contained in combinations
    i need the following output
    COMB_ID COMB_NAME SUBJECT1 SUBJECT2      SUBJECT3      SUBJECT4
    383     S1     Biology Chemistry      Computer Science Physics
    384     S2     Chemistry Computer Science Mathematics Physics
    or even this is enough(what i actually needed)
    COMB_ID     subjects
    383           Biology,Chemistry,Computer Science,Physics
    384           Chemistry,Computer Science,Mathematics,Physics
    you can use any of the COMBINATION table(either (2) or (3))
    and i want to know
    1)which design is good in this case
    (i think SUB_ID1,SUB_ID2,SUB_ID3,SUB_ID4 is not a
    good method to link with same table but if 4 subjects only(and must) comes
    detail table is not neccessary )
    now i am achieving the result by program-coding in C# after getting the rows from oracle
    i am using oracle 9i (also ODP.NET)
    i want to know how can i get the result in the stored procedure itsef.
    2)how it could be designed in any other way.
    any help/suggestion is welcome
    thanks for your time --Pradeesh

    Well I forgot the table-alias, here now with:
    SELECT C.COMB_ID
    , C.COMB_NAME
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID1) AS SUBJECT_NAME1
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID2) AS SUBJECT_NAME2
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID3) AS SUBJECT_NAME3
    , (SELECT SUB_NAME
    FROM SUBJECTS
    WHERE SUB_ID = C.SUB_ID4) AS SUBJECT_NAME4
    FROM COMBINATION C;
    As you need exactly 4 subjects, the columns-solution is just fine I would say.

  • Color management help needed for adobe CS5 and Epson printer 1400-Prints coming out too dark with re

    Color management help needed for adobe CS5 and Epson printer 1400-Prints coming out too dark with reddish cast and loss of detail
    System: Windows 7
    Adobe CS5
    Printer: Epson Stylus Photo 1400
    Paper: Inkjet matte presentation paper with slight luster
    Installed latest patch for Adobe CS5
    Epson driver up to date
    After reading solutions online and trying them for my settings for 2 days I am still unable to print what I am seeing on my screen in Adobe CS5. I calibrated my monitor, but am not sure once calibration is saved if I somehow use this setting in Photoshop’s color management.
    The files I am printing are photographs of dogs with lots of detail  I digitally painted with my Wacom tablet in Photoshop CS5 and then printed with Epson Stylus 1400 on inkjet paper 20lb with slight luster.
    My Printed images lose a lot of the detail & come out way to dark with a reddish cast and loss of detail when I used these settings in the printing window:
    Color Handling: Photoshop manages color, Color management -ICM, OFF no color adjustment.
    When I change to these settings in printer window: Color Handling:  Printer manages color.  Color management- Color Controls, 1.8 Gamma and choose Epson Standard it prints lighter, but with reddish cast and very little detail and this is the best setting I have used so far.
    Based on what I have read on line, I think the issue is mainly to do with what controls are set in the Photoshop Color Settings window and the Epson Printer preferences. I have screen images attached of these windows and would appreciate knowing what you recommend I enter for each choice.
    Also I am confused as to what ICM color management system to use with this printer and CS5:
    What is the best ICM to use with PS CS5 & the Epson 1400 printer? Should I use the same ICM for both?
    Do I embed the ICM I choose into the new files I create? 
    Do I view all files in the CS5 workspace in this default ICM?
    Do I set my monitor setting to the same ICM?
    If new file opens in CS5 workspace and it has a different embedded profile than my workspace, do I convert it?
    Do I set my printer, Monitor and PS CS5 color settings to the same ICM?
    Is using the same ICM for all devices what is called a consistent workflow?
    I appreciate any and all advice that can be sent my way on this complicated issue. Thank you in advance for your time and kind help.

    It may be possible to figure out by watching a Dr.Brown video on the subject of color printing. Adobe tv
    I hope this may help...............

  • WHICH JDK java hotspot I  need for weblogic 10.3.6  SOA 11.1.1.7 and OSB 11.1.1.7

    I used jrockit but somebody told me that It will be good to move to JDK 1.7.0.28 because jrockit will gone in future.
    WHICH JDK java hotspot I  need for weblogic 10.3.6  SOA 11.1.1.7 and OSB 11.1.1.7?
    and where can I download it?
    Thank you

    Hi,
    For WL 10.3.6, SOA/OSB 11.1.1.7 the Enterprise Deployment Guide has still jrockit sdk 1.6 as recommendation...
    http://docs.oracle.com/cd/E28280_01/core.1111/e12036/create_domain.htm#CCHBFCDC
    The roadmap is to converge jrockit and hotspot JVMs, completion of the convergence project is targeted for JDK 8.
    http://www.oracle.com/us/corporate/press/1854982
    Things are already changed for 12c, but for 11g I'd still go with jrockit...
    Cheers,
    Vlad

  • Help need for force to signout All session ! how...

    hi
         help need for force to  signout All session !  how ??
    Solved!
    Go to Solution.

    Hi and welcome to the Skype Community,
    To force a signout of all instances your Skype is signed into please change your password: https://support.skype.com/en/faq/FA95/how-do-i-change-my-password
    Follow the latest Skype Community News
    ↓ Did my reply answer your question? Accept it as a solution to help others, Thanks. ↓

  • HELP NEED FOR INVOKING THE JAVA CODE INSIDE JSP

    Hello,
    any one knows how to Write a java code inside the .jsp files... please if any one knows it please ....help me .....

    hi .
    Use scriptlets , for example :
    <html>
    <%
    int x;
    for(x=1;x<=5;x++)
    out.println(x);
    %>
    </html>

  • Java newbie help: Need to change a graphic on screen

    Hello everyone. I'm a long time C/C++ programmer, and I've been thrust into the Java world when I inherited an incomplete project. If something I mention later on sounds stupid, it's probably because it came that way, or I'm trying to force it into what I know from old experience.
    FWIW, the project is being developed with Netbeans.
    What I'm after is how to change a graphic object onscreen from within the code, vs. with a device such as a mouse. I'm trying to emulate an LED indicator.
    What I've done so far is to try using the enable state, and defining GIFs to display. That didn't work.
    I've switched gears a bit, and tried something similar with the selected property, but that will only work if I hit the item with my mouse and click. Also, the item is defined as a jToggleButton.
    In general terms, what do I need to do to set this up for the displayed item to change without device input? I've been reading stuff about Buttons, ToggleButtons, Graphics, Images, and Icons, and I'm waaaaaay lost right now.
    To add to the frustration is that I've done something similar with Visual C++, and that worked as intended. Harumph.
    Help?!?

    FWIW, the project is being developed with Netbeans.
    In case you don't know, you can use any editor to develop java code.
    What I'm after is how to change a graphic object onscreen from within the code, vs. with a device such as a mouse. I'm trying to emulate an LED indicator.
    What I've done so far is to try using the enable state, and defining GIFs to display. That didn't work.
    What happend?
    I've switched gears a bit, and tried something similar with the selected property, but that will only work if I hit the item with my mouse and click. Also, the item is defined as a jToggleButton.
    Is this not what you wanted?

  • Search java code help

    I am writing a small Java program and need help using a simple search code. Here is the code
    public int indexOf(EltType e) {
            int i=0;
            for (i = currsize; i < currsize; i++){
                things[i] = e;
                e.equals(get(i));
            return -1;
        }Basically I want to search the array for e, and return its position, or -1 if e is not found. I know I have to use .equals(i) to compare e and get(i) but unsure where it goes.
    Here is the method that calls it:
    public void searchtester() {
            MyList<String> searchlist = new MyList<String>();
            searchlist.add("tangerine");
            searchlist.add("apple");
            searchlist.add("mango");
            searchlist.add("lime");
            searchlist.add("carrot");
            for (int i = 0; i<searchlist.size(); i++)
            System.out.println("searching for \"" + searchlist.get(i) + "\", result="
                + words.indexOf(searchlist.get(i)));
        }Please let me know what I am doing wrong.

    middle wrote:
    sorry kevinaworkman, not trying to ignore any advice, just very new to java so trying to figure this out. It's okay, I just know from experience that breaking it up into smaller pieces will save you a ton of headaches.
    Ok so I would imagine that loop:
    for (i = currsize; i < currsize; i++)would run onceTake a look at the tutorial on [the for statement|http://java.sun.com/docs/books/tutorial/java/nutsandbolts/for.html] . If i starts out equal to currsize, and is only ever incremented, when will it be less than currsize? But even assuming that the loop runs once, what good would that be? Wouldn't you want the loop to run as many times as there are elements in your array?
    things[i] = e;I'll give you a hint: if this line were executed, it would set the element at position i in the array equal to e. You want to check for equality, not set the whole array equal to e, right? Do you mean == in an if statement?
    e.equals(get(i));Again, if this line was executed, it would check for equality between e and whatever get(i) returns. But then what are you doing with that boolean?
    I want to see if i is equal to e then the result I want is the position of e and if i does not equal e then I want it to result in a -1, the issue is that it is giving me "-1" for all the results when I know that the first 3 items are in the list.You might want to step through your program with a debugger to see what's happening line by line. Or better yet, step through it with a piece of paper and a pencil. Go through the program as if you were the computer, following your program (and not the logic in your head you think the program does) exactly.
    Some other things you might want to consider: the [if statement|http://java.sun.com/docs/books/tutorial/java/nutsandbolts/if.html] , arrays , and the above mentioned for loop tutorials.

  • KeyListener Help Needed for Tetris Game!

    * Tetris - Java Enhacned
    * By: Kunnel Zachariah, Johnathan Smith, Johnathan Adkins
    import javax.swing.JFrame;
    import java.awt.Color;
    import java.awt.Graphics;
    import javax.swing.Timer;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.awt.event.KeyListener;
    import java.awt.event.KeyEvent;
    import static java.lang.Character.*;
    import java.awt.*;
    import java.awt.image.*;
    import java.applet.*;
    import java.lang.Math;
    import java.lang.System;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.Random;
    import java.awt.event.KeyAdapter;
    public class TetrisMain extends JFrame implements KeyListener
         int s;
         int p;
         int xPos;
         int yPos;
         int level = 1;
         int lines = 0;
         int score = 0;
         int switchPiece;
         private boolean[] keys;
         private int SLEEP = 50; //bigger # = slower animation
         private Timer timer;
         int bologna = 11;
        int posX[], posY[];
         Color color;
         boolean isSquare = false;
         public TetrisMain()
              setSize(550,710);
              setBackground(Color.black);
              setVisible(true);
              getContentPane();
         public static void main( String args[] )
              TetrisMain pongLab = new TetrisMain();
        public void paint (Graphics g)
              s=0;
              keys = new boolean[4];
              this.addKeyListener(this);
              g.setColor(Color.blue);
              g.fillRect(0,0,550,710);
              g.setColor(Color.black);
              g.fillRect(0,0,460,600);          
              g.setColor(Color.blue);
              g.setColor (Color.black);          
              g.setFont(new Font("Helvetica",Font.BOLD,14));
            g.drawString ("Level: " + level, 485, 40);
            g.drawString ("Lines: " + lines, 485, 80);
            g.drawString ("Score: " + score, 485, 120);
             ActionListener paintCaller = new ActionListener(){
                   public void actionPerformed(ActionEvent event)
                        repaint();  //recalls paint every SLEEP milliseconds
              timer = new Timer(SLEEP, paintCaller);
              timer.start();
              while (bologna <= 30)
             if ( keys[0] == true )
                   //move left paddle up and draw it on the window
                   s+=3;
              if ( keys[1] == true )
              //move left paddle down and draw it on the window
                   p+=3;
              if ( keys[2] == true )
                   s-=3;
              if ( keys[3] == true )
                   p-=3;
                        displayRandomPiece(g);
                        bologna++;
      public void drawGridVertical(Graphics g)
             for(xPos = 0; xPos <=460; xPos+=23)
             for(yPos=0; yPos <=600; yPos+=23)
                  g.drawLine(xPos,yPos,xPos,yPos);
        public void drawBlock(Graphics g)
         ImageIcon animatedIcon1 = new ImageIcon("untitled.gif");
         for(p =0; p <=530; p+=2)
          animatedIcon1.paintIcon(this,g,s,p);
          delay(100000);
        public void drawTpiece(Graphics g)
           ImageIcon animatedIcon = new ImageIcon("tpiece.gif");
          for(p =0; p <=530; p+=2)
          animatedIcon.paintIcon(this,g,s,p);
          delay(100000);
        public void drawZigZagpiece(Graphics g)
         ImageIcon animatedIcon2 = new ImageIcon("zigzagpiece.gif");
         for(p =0; p <=530; p+=2)
          animatedIcon2.paintIcon(this,g,s,p);
          delay(100000);
        public void Rectanglepiece(Graphics g)
             ImageIcon animatedIcon3 = new ImageIcon("rectangle.gif");
         for(p =0; p <=530; p+=2)
          animatedIcon3.paintIcon(this,g,s,p);
          delay(100000);
        public void Unknownpiece(Graphics g)
             ImageIcon animatedIcon4 = new ImageIcon("unknownpiece.gif");
         for(p =0; p <=530; p+=2)
          animatedIcon4.paintIcon(this,g,s,p);
          delay(100000);
        public void otherZigZagpiece(Graphics g)
             ImageIcon animatedIcon5 = new ImageIcon("otherzigzagpiece.gif");
          for(p =0; p <=530; p+=2)
          animatedIcon5.paintIcon(this,g,s,p);
          delay(100000);
         public void otherUnknownpiece(Graphics g)
             ImageIcon animatedIcon6 = new ImageIcon("otherunknownpiece.gif");
         for(p =0; p <=530; p+=2)
          animatedIcon6.paintIcon(this,g,s,p);
          delay(100000);
        public static void delay(double n)
              for (double x = 0; x <= n; x += .01);
          public boolean keyPressed(Event e, int key)
          if (key == Event.LEFT)
            s=-1;
          else if (key == Event.RIGHT)
            s+=1;
          else if (key == Event.UP)
            p-=1;
          else if (key == Event.DOWN)
          //  fast=true;
          else if (key == Event.ESCAPE)
           // ingame=false;
        return true;
         public void keyPressed(KeyEvent e)
              System.out.println("keypressed");
              switch(toUpperCase(e.getKeyChar()))
                   case 'W' : keys[0]=true;System.out.println("W keypressed"); break;
                   case 'Z' : keys[1]=true; System.out.println("z keypressed");break;
                   case 'I' : keys[2]=true; System.out.println("i keypressed");break;
                   case 'M' : keys[3]=true; System.out.println("m keypressed");break;
         public void keyReleased(KeyEvent e)
              System.out.println("released");
              switch(toUpperCase(e.getKeyChar()))
                   case 'W' : keys[0]=true; System.out.println("W realeased");break;
                   case 'Z' : keys[1]=true; System.out.println("Z realeased");break;
                   case 'I' : keys[2]=true; System.out.println("i realeased");break;
                   case 'M' : keys[3]=true; System.out.println("m realeased");break;
         public void keyTyped(KeyEvent e)
              //no code needed here
      public void displayRandomPiece(Graphics g)
           Random rand = new Random();
           int c = rand.nextInt((7)+1);
           switch(c)
                case 1:
                drawBlock(g);
                break;
                case 2:
                drawTpiece(g);
                break;
                case 3:
                drawZigZagpiece(g);
                break;
                case 4:
                Rectanglepiece(g);
                break;
                case 5:
                Unknownpiece(g);
                break;
                case 6:
                otherZigZagpiece(g);
                break;
                case 7:
                otherUnknownpiece(g);
                break;
    }This is my code so far for Tetris. I am having issues with my keylisteners! I keep pressing the specified keys and the println statements wont show up or the piece wont move! i really need major help. can anyone give me some advice
    Much Thanks,
    Chris!

    http://forum.java.sun.com/thread.jspa?threadID=5175447
    Don't double post! No help for you!

  • Help needed for Project Work

    +People..I am new to this forum and your help is absolutely essential as it for my project work. There are two questions in my project. This is the second one. The first question is at the following thread.
    http://forum.java.sun.com/thread.jspa?threadID=5220057
    Thanks in advance..+*
    This is the Question
    Create a class ToyCollection that stores information about different toys in a toy shop.  The information to be stored about a single toy is,
    -         Toy identification as String
    -         Name of the toy as String
    -         Short description about the toy as a String
    -         Price of the toy as float
    -         Quantity of the toy in hand as short integer.
    This class contains following methods,
    -         Constructor method that assigns user input values to above mentioned variables.
    -         main ( ) method that creates array of 4 objects of ToyCollection class and that takes input for all above details from the user and
    calls method to check validity of Quantity and Price values. If all values are valid then create the objects and display the details
    for all 4 toys.
    -         Method that checks validity of quantity and price. If the quantity is 0 or negative then method should throw user defined
    exception with appropriate message and come out of program. Similarly if the price is 0 or negative then it should throw user defined exception with appropriate message and come out of program.
    -         Method that displays all details about a single toy in the following format, e.g. Here Total price should be calculated.
    Toy Identification                  :  S-1
    Toy Name                            :  Small Scooter
    Toy Description                    :  Ordinary 3 wheeler scooter
    Toy price                              :   650.50
    Quantity in hand                    :   3
    Total price of Toys               :    1951.50
    And i did the following coding
    import java.io.*;
    import java.lang.*;
    public class ToyCollection
         public int toyid;
         public String toyname;
         public String toydetails;
         public float toyprice;
         public int toyquantity;
         public void setToyid(int tid)
              toyid = tid;
         public void setToyname(String tname)
              toyname = tname;
         public void setToydetails(String tdet)     
              toydetails = tdet;
         public void setToyprice(float tpri)
              toyprice = tpri;
         public void setToyquantity(int tquan)
              toyquantity = tquan;
         public int getToyid()
              return toyid;
         public String getToyname()
              return toyname;
         public String getToydetails()     
              return toydetails;
         public float getToyprice()
              return toyprice;
         public int getToyquantity()
              return toyquantity;
         public static void main(String args[])throws Exception
              ToyCollection a=new ToyCollection();
              System.out.println("Enter the Toy id");
              BufferedReader br1=new BufferedReader(new InputStreamReader(System.in));
              int tid=Integer.parseInt(br1.readLine());
              a.setToyid(tid);
              System.out.println("Enter the Toy name");
              BufferedReader br2=new BufferedReader(new InputStreamReader(System.in));
              String tname=br2.readLine();
              a.setToyname(tname);
              System.out.println("Enter the Toy details");
              BufferedReader br3=new BufferedReader(new InputStreamReader(System.in));
              String tdet=br3.readLine();
              a.setToydetails(tdet);
              System.out.println("Enter the Toy price");
              BufferedReader br4=new BufferedReader(new InputStreamReader(System.in));
              float tpri=Float.parseFloat(br4.readLine());
              a.setToyprice(tpri);
              System.out.println("Enter the Toy quantity");
              BufferedReader br5=new BufferedReader(new InputStreamReader(System.in));
              int tquan=Integer.parseInt(br5.readLine());
              a.setToyquantity(tquan);
              System.out.println("The Toy Attributed you entered are displayed below \n" + " ID :" + a.getToyid() + "\n " +" Name :" + a.getToyname() + "\n " + " Details :" + a.getToydetails() + "\n " + " Price :" + a.getToyprice() + "\n " + " Quantity :" + a.getToyquantity());
    I submitted the above coding and this was the response from the evaluator
    *"You need to create array of toys. You are accepting details of toy in a single line and your program ends."*
    Eagerly awaiting your reply at the earliest people.

    DrLaszloJamf , here is the question.
    Create a class ToyCollection that stores information about different toys in a toy shop. The information to be stored about a single toy is,
    - Toy identification as String
    - Name of the toy as String
    - Short description about the toy as a String
    - Price of the toy as float
    - Quantity of the toy in hand as short integer.
    This class contains following methods,
    - Constructor method that assigns user input values to above mentioned variables.
    - main ( ) method that creates array of 4 objects of ToyCollection class and that takes input for all above details from the user and
    calls method to check validity of Quantity and Price values. If all values are valid then create the objects and display the details
    for all 4 toys.
    - Method that checks validity of quantity and price. If the quantity is 0 or negative then method should throw user defined
    exception with appropriate message and come out of program. Similarly if the price is 0 or negative then it should throw user defined exception with appropriate message and come out of program.
    - Method that displays all details about a single toy in the following format, e.g. Here Total price should be calculated.
    Toy Identification : S-1
    Toy Name : Small Scooter
    Toy Description : Ordinary 3 wheeler scooter
    Toy price : 650.50
    Quantity in hand : 3
    Total price of Toys : 1951.50
    What is the java code for the above ?

  • A little help needed for card drawing

    i was told to write a program in java for a friend, i know almost nothing of java, and came here for help
    -i need a class that draws 1 card from a 52 card deck and displays the value of the card.
    -a class that will draw 5 cards from a deck of cards 9 ? A (single deck) and displays them.
    thanks in advance.
    again, im not a programmer, but any suggestions are helpful maybe some code to start me out.

    HermTheWorm wrote:
    i was told to write a program in java for a friend, i know almost nothing of java, and came here for help
    -i need .....
    again, im not a programmer, but any suggestions are helpful maybe some code to start me out.From your Nov 1 post: http://forum.java.sun.com/thread.jspa?threadID=5232501
    hello, i am making a hall pass program for my computer programming class. i am having issues with my jcheckboxes. first off. this file reads from a .txt that just has
    greg
    john
    ...Sorry, but something about all this strikes me as being a bit odd. Maybe it's just me.

  • Help needed for using BASIC authentication through JDBCRealm

    Help needed.
    Hello,
    I am doing a degree project, so far it works fine in my local machine, I need to try it on my virtual hosting (as it is a live server).
    My project requires JDBCRealm, that is BASIC authentication loading access data from mysql database. Normally this setup can be done in Server.xml file, because my Tomcat hosting is a virtual one, I only have permission to access the web.xml file.
    My question is: is it possible to get it done in an alternative way? In web.xml? Some properties file maybe?
    Thank you very much.

    You can set this up for your context using META-INF/context.xml instead of working with server.xml.
    Make a directory called META-INF under your webapp ( it'll be at the same level as WEB-INF ). Under this, add a context.xml with all your context specific configuration including the realm. A sample is below
    <?xml version="1.0" encoding="UTF-8"?>
    <Context path="/myApp" reloadable="true">
        <Realm
            className="org.apache.catalina.realm.JDBCRealm"            
            driverName="com.microsoft.jdbc.sqlserver.SQLServerDriver"         
            connectionURL="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=myDB;SelectMethod=Cursor;"
            connectionName="username" connectionPassword="password"
            digest="MD5" userTable="users" userNameCol="userid" userCredCol="userpassword"
            userRoleTable="user_roles" roleNameCol="rolename"
        />
    </Context>Hope this helps.
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    ----------------------------------------------------------------

Maybe you are looking for