I need help with a java assignment

I am being taught java but dont really understand what i have to do. If you send me an email to [email protected] ill send you a copy and so help me with the assignement.
I am currently working on free web page so you can download the assignment.
Thank You All

hey, there's something wrong with my internet, i clicked on your email adress and nothing happened :(
too bad. maybe i can't do your assignment.
go see somee tutorials, maybe these will help you, also try to understand how API will elp you (to both you may find links from left column of this page) and also, see if there area some samples of how to do what you need to be done.
http://www.javaalmanac.com -- my favorited place for code samples.
also whan you have some saaignment or other task, then see if google finds you apropriate solution. and there's a search function in these forums as well.
i hope you get your homework doen in time...

Similar Messages

  • Need help for a java assignment

    i am having trouble with my java assignment, so i thought i will give it a try here and hope that i will get some help. ^^
    the method is to load a file and try to create an object out of it. but even though the sequence of loading is correct, the method still doesn't work. there is no error in compilation and the coding seems correct to me. help?
    the codes are below and if any other code is needed. ask me for it. =)
    public void saveToFile(String fileName)
    try
    File f = new File(fileName);
    PrintWriter p = new PrintWriter(f);
    p.println(fileName);
    p.println("***");
    for(int i =0; i<categories.length; i++)
    if(categories[i] != null)
    p.print(categories.getCatNum());
    Car[] x = categories[i].getListOfCars();
    for(int q=0; q<x.length;q++)
    if(x[q] != null)
    if(x[q] instanceof EconomyCar)
    p.print("Economy Car");
    x[q].getCarNum();
    x[q].getBrand();
    x[q].getPrice();
    else if(x[q] instanceof LuxuryCar)
    p.print("Luxury Car");
    x[q].getCarNum();
    x[q].getBrand();
    x[q].getPrice();
    else if(x[q] instanceof SportCar)
    p.print("Sport Car");
    x[q].getCarNum();
    x[q].getBrand();
    x[q].getPrice();
    p.println(x[q].getCarNum());
    p.println(x[q].getBrand());
    p.println(x[q].getPrice());
    p.close();
    catch(IOException e)
    System.out.println("IO Error");
    public void loadFromFile(String fileName)
    try
    File file = new File(fileName);
    Scanner sc = new Scanner(file);
    String shopName = sc.nextLine();
    CarMart Cm = new CarMart(shopName);
    while(sc.hasNextLine());
    String line = sc.nextLine();
    while(line.equals("***"));
    int CateNum = sc.nextInt(); sc.nextLine();
    Category Cate = new Category(CateNum);
    String typeOfCar = sc.nextLine();
    if(typeOfCar.equals("Economy Car"))
    String CarNum = sc.nextLine();
    String brand = sc.nextLine();
    double price = sc.nextDouble(); sc.nextLine();
    EconomyCar e = new EconomyCar(CarNum, brand, price);
    else if(typeOfCar.equals("Luxury Car"))
    String CarNum = sc.nextLine();
    String brand = sc.nextLine();
    double price = sc.nextDouble(); sc.nextLine();
    LuxuryCar l = new LuxuryCar(CarNum, brand, price);
    else if(typeOfCar.equals("Sport Car"))
    String CarNum = sc.nextLine();
    String brand = sc.nextLine();
    double price = sc.nextDouble(); sc.nextLine();
    SportCar s = new SportCar(CarNum, brand, price);
    sc.close();
    catch(FileNotFoundException a)
    System.out.println("Filename not found");

    morgalr wrote:
    erm. its supposed to save a file containing all the data of a car. then the loadFromFile method is supposed to load that file and create a car out of it.I want one, could you please make mine a Dodge Viper.A fascinating insight into your secret worries about your masculinity :)

  • Need Help with a JAVA programming assignment

    How do I write a JAVA program that could be used as the start of an MS-DOS/Windows simulation of the IEEE 802.3 protocol? I am to only code the parts necessary to build the 802.3 frame. For the initial implementation, the Checksum function need not be a CRC function, and the Destination and Source addresses wil be in input, stored, and output, and in dotted-decimal format.
    I need:
    1. A record to describe the frame, with each field being a (byte-) string of the required size, except that the Data field is of variable size. Although the "Source address" and "Destination address" would be 6 bytes for a real implementation, for this first implementation you can either assume they'll be text strings in the usual "dotted decimal" form (e.g. "14.04.05.18.01.25" as a typical example--from Tanenbaum, p. 429), or 6 hex digits.
    2. Suitable constant declarations for values such as the standard "Preamble" and "Start of Frame" values.
    3. Suitable functions to Get the three variable values "Destination address", "Source address", and "Data" from the standard input device.
    4. A suitable function to display each of the fields of a given frame in a format such as:
    Preamble: ...
    StartofFrame: ...
    Destination: ...
    etc.
    5. A suitable function to generate a "Pad" field if necessary.
    6. A "dummy" Checksum-generating function which just takes the first 32 bits (4 bytes) of the Data (or Data+Pad, if necessary) rather than an actual CRC algorithm.
    I have no experience with Java. Can you help me or start me in the right direction?
    Thanks...........TK

    If you have no experience with Java, then it seems to me your first step should be to start learning the language. But it's difficult to advise how, since we don't know anything about your background. There are many good books available on Java, some are for beginners and some are for advanced programmers, so I'd suggest you go somewhere that has a large selection and start looking for something that doesn't seem completely over your head.

  • Need help with error java.lang.IllegalArgumentException: timestamp on bar b

    My company uses Java based applications for real time streaming stock market information and I have come across 2 users that are generating the same error:
    Bar.addBar failed adding com.abwg.bar.BasicBar 20071210-08:27:00.000 104.34 104.35 104.25 104.25 950 to com.abwg.bar.BasicBar 20071210-09:30:00.000 104.11 104.38 104.11 104.38 436 :java.lang.IllegalArgumentException: timestamp on bar being combined older than original bar
    I have had no luck trying to determine what the cause of this error is, however both users experience very laggy performance shortly after launching the application. I have not been able to duplicate the problem, and the developers have not been able to provide any response or possible causes yet.
    I'd be very appreciative if anyone could help me make some sense of what this error type might mean. It's got something to do with the computer that the application is being run on. One user is on a Mac 10.3 using J2SE 1.4.2_12 and the other is on Win XP using Java 1.6_3

    Thank you Frank and Carole for your response. The stated issue/error is resolved. It had to do with the upgrade somehow which lead to multiple certs for the same agent. Anyway, I had to delete ADS and all attached Agents,  re-create ADS, re-create all Agents and re-register with the new ADS. I then manually re-registered the Directory Server instances on both the Primary and Secondary Servers with the new ADS. Voila, the DSCC Web console no longer prompts for server credentials.
    But importing the Wild card cert issue still remains. I added the issuing CA chain to the ldap instance CA store and I see the certs listed. But when I try to import the P12 cert/key combo, I get an error which says something like: "The certificate is already in the database". But it is not, verified using certutil.
    Yes internal CA or Self-signed Certs are fine. If I add the internal CA and Root CA to the cert store on my LDAP clients, then I am fine. No SSL errors. But want to avoid using such as we do have quite a few clients which would be connecting to the store. Hence want to use our  enterprise wild card Cert. I am not sure if it is an issue importing a wild card pkcs12 format.
    As mentioned above I did add the CA chain (which issued the wild card) to the actual instance, not the ADS. I can try that. But are you sure we need to add the Root CA to Tomcat ks.
    And while we are at it, the Self-signed certs generated using the Console is only valid for 2 years. Is it possible to change the term ?
    Thanks again.

  • 1941w - Need help with IP address assigning, and relay wireless to a DHCP server.

    Hope someone can point me in the right direction -
    Basically have a Win08 R2 DHCP server, and a 1941w router.
    I've got the internet, got the lan clients getting DHCP ok (with ip helper-address set on the 0/0 internal interface).
    Also have the SSID, and wireless clients can connect - but no IPs are being handed out, also not sure if I understand or did the bridging correctly or assigned IPs to the vlan or bvi1 correctly.
    for ex:
    DHCP server IP:
    10.10.2.4
    Router Ethernet internal interface 0/0 IP:
    10.10.2.1
    with helper-address 10.10.2.4 (lan clients are resolving IPs correctly from the DHCP server)
    Vlan1 IP address:
    10.10.3.1
    Does this interface need the helper-address as well? (10.10.2.4)?
    wlan-ap 0 IP address:
    unnumbered
    interface BVI1 IP address (static):
    10.10.2.2
    am i totally off? not even sure if i have the vlan bridged to the 0/0 adapter or not correctly - but as I said, i can get a wireless client to connect with the SSID.
    would appreciate any advice/pointers, thanks

    of course - here is the router config:
    =======================================================
    Using 5591 out of 262136 bytes
    version 15.1
    no service pad
    service tcp-keepalives-in
    service tcp-keepalives-out
    service timestamps debug datetime msec localtime show-timezone
    service timestamps log datetime msec localtime show-timezone
    service password-encryption
    service sequence-numbers
    hostname router
    boot-start-marker
    boot-end-marker
    security authentication failure rate 3 log
    security passwords min-length 6
    logging buffered 51200
    logging console critical
    enable secret 5 $1$JWwK$.04.NFg7tQ82UTy68/hyv.
    no aaa new-model
    service-module wlan-ap 0 bootimage autonomous
    no ipv6 cef
    no ip source-route
    ip cef
    no ip bootp server
    ip name-server 10.10.2.4
    multilink bundle-name authenticated
    crypto pki token default removal timeout 0
    crypto pki trustpoint TP-self-signed-975501586
    enrollment selfsigned
    subject-name cn=IOS-Self-Signed-Certificate-975501586
    revocation-check none
    rsakeypair TP-self-signed-975501586
    crypto pki certificate chain TP-self-signed-975501586
    certificate self-signed 01 nvram:IOS-Self-Sig#3.cer
    license udi pid CISCO1941W-A/K9 sn FTX155085QG
    hw-module ism 0
    ip tcp synwait-time 10
    ip ssh time-out 60
    ip ssh authentication-retries 2
    interface Embedded-Service-Engine0/0
    no ip address
    no ip redirects
    no ip unreachables
    no ip proxy-arp
    ip flow ingress
    shutdown
    interface GigabitEthernet0/0
    description $ETH-LAN$$ETH-SW-LAUNCH$$INTF-INFO-GE 0/0$$ES_LAN$$FW_INSIDE$
    ip address 10.10.2.1 255.255.255.0
    ip helper-address 10.10.2.4
    no ip redirects
    no ip unreachables
    no ip proxy-arp
    ip flow ingress
    ip nat inside
    ip virtual-reassembly in
    duplex auto
    speed auto
    no mop enabled
    interface wlan-ap0
    description Service module interface to manage the embedded AP
    ip unnumbered GigabitEthernet0/0
    no ip redirects
    no ip unreachables
    no ip proxy-arp
    ip flow ingress
    arp timeout 0
    no mop enabled
    no mop sysid
    interface GigabitEthernet0/1
    description $ES_WAN$$FW_OUTSIDE$
    ip address dhcp client-id GigabitEthernet0/1
    no ip redirects
    no ip unreachables
    no ip proxy-arp
    ip flow ingress
    ip nat outside
    ip virtual-reassembly in
    duplex auto
    speed auto
    no mop enabled
    interface Wlan-GigabitEthernet0/0
    description Internal switch interface connecting to the embedded AP
    no ip address
    interface Vlan1
    ip address 10.10.3.1 255.255.255.0
    ip helper-address 10.10.2.4
    no ip redirects
    no ip unreachables
    no ip proxy-arp
    ip flow ingress
    ip forward-protocol nd
    ip http server
    ip http authentication local
    ip http secure-server
    ip http timeout-policy idle 60 life 86400 requests 10000
    ip nat inside source list 1 interface GigabitEthernet0/1 overload
    logging trap debugging
    access-list 1 remark INSIDE_IF=GigabitEthernet0/0
    access-list 1 remark CCP_ACL Category=2
    access-list 1 permit 10.10.2.0 0.0.0.255
    no cdp run
    control-plane
    line con 0
    login local
    transport output telnet
    line aux 0
    login local
    transport output telnet
    line 2
    no activation-character
    no exec
    transport preferred none
    transport input all
    transport output pad telnet rlogin lapb-ta mop udptn v120 ssh
    stopbits 1
    line 67
    no activation-character
    no exec
    transport preferred none
    transport input all
    transport output pad telnet rlogin lapb-ta mop udptn v120 ssh
    line vty 0 4
    privilege level 15
    login local
    transport input telnet ssh
    line vty 5 15
    privilege level 15
    login local
    transport input telnet ssh
    scheduler allocate 20000 1000
    end
    =======================================================
    and the ap config:
    =======================================================
    Using 2067 out of 32768 bytes
    version 12.4
    no service pad
    service timestamps debug datetime msec
    service timestamps log datetime msec
    service password-encryption
    hostname ap
    enable secret 5 $1$xKDT$GdLGeA6h.H9LKL9l3dPmj.
    no aaa new-model
    dot11 syslog
    dot11 ssid WIFI1
       vlan 1
       authentication open
       authentication key-management wpa
       mbssid guest-mode
       wpa-psk ascii 7 044B1E030D2D43632A
    bridge irb
    interface Dot11Radio0
    no ip address
    no ip route-cache
    encryption vlan 1 mode ciphers aes-ccm
    broadcast-key vlan 1 change 30
    ssid WIFI1
    antenna gain 0
    station-role root
    interface Dot11Radio0.1
    encapsulation dot1Q 1 native
    no ip route-cache
    bridge-group 2
    bridge-group 2 subscriber-loop-control
    bridge-group 2 block-unknown-source
    no bridge-group 2 source-learning
    no bridge-group 2 unicast-flooding
    bridge-group 2 spanning-disabled
    interface Dot11Radio1
    no ip address
    no ip route-cache
    encryption vlan 1 mode ciphers aes-ccm
    broadcast-key vlan 1 change 30
    ssid WIFI1
    antenna gain 0
    dfs band 3 block
    channel dfs
    station-role root
    interface Dot11Radio1.1
    encapsulation dot1Q 1 native
    no ip route-cache
    bridge-group 2
    bridge-group 2 subscriber-loop-control
    bridge-group 2 block-unknown-source
    no bridge-group 2 source-learning
    no bridge-group 2 unicast-flooding
    bridge-group 2 spanning-disabled
    interface GigabitEthernet0
    description  the embedded AP GigabitEthernet 0 is an internal interface connecting AP with the host router
    no ip address
    no ip route-cache
    interface GigabitEthernet0.1
    encapsulation dot1Q 1 native
    no ip route-cache
    bridge-group 1
    no bridge-group 1 source-learning
    bridge-group 1 spanning-disabled
    interface BVI1
    ip address 10.10.2.2 255.255.255.0
    no ip route-cache
    ip http server
    no ip http secure-server
    ip http help-path http://www.cisco.com/warp/public/779/smbiz/prodconfig/help/eag
    bridge 1 route ip
    line con 0
    no activation-character
    line vty 0 4
    login local
    end
    ============================================

  • Need help with basic Java programming

    I'm having a little bit of trouble with my code. For the sake of argument, I've removed the code I'm having trouble with, because I know it was inaccurate. I'm trying to create a loop so that this program will keep going through and through until the user enters an invalid variable. I thought the default after the case statements was supposed to make the system exit and output my message. Those two problems, the loop and the default, are what I'm really having problems with. My code is posted below.
    import javax.swing.JOptionPane;
    import java.util.Locale;
    import java.text.NumberFormat;
    public class Retail
    public static void main(String args[])
    String firstNum;
    String secondNum;
    String result;
    int prodNum;      //first number to input
    double quantity; //second number to input
    double total = 0.0;     //total of Prod * Quantity Sold for all items
    // To use American Dollar
    NumberFormat moneyFormat = NumberFormat.getCurrencyInstance( Locale.US );
    // first number entered as string
    firstNum = JOptionPane.showInputDialog( "Enter product number 1-5" );
    // second number entered as string
    secondNum = JOptionPane.showInputDialog( " Enter quantity of items sold" );
    // convert values to type double or int from type string
    prodNum = Integer.parseInt( firstNum );
    quantity = Double.parseDouble( secondNum);
    result="";
    if ( prodNum >=1 && prodNum <=5 ) {
    switch (prodNum)
    case 1: // 1st product
    total = 2.98 * quantity;
    break;
    case 2: // 2nd product
    total = 4.50 * quantity;
    break;
    case 3: // 3rd product
    total = 9.98 * quantity;
    break;
    case 4: //4th product
    total = 4.49 * quantity;
    break;
    case 5:
    total = 6.87 * quantity;
    break;
    default: JOptionPane.showMessageDialog( null, "Wrong product number entered" );
    JOptionPane.showMessageDialog( null, moneyFormat.format(total), "Total Price of Items Purchased", JOptionPane.INFORMATION_MESSAGE );
    System.exit(0);
    ***I know I need to put something in the user input message to state that any value other than 1-5 entered will cause the program to skip to the output, I'll put that in later.***

    When you post code, please use [code] and [/code] tags as described in Formatting Help on the message entry page. It makes it much easier to read and prevents accidental markup from array indices like [i].

  • Need Help With NetBeans (Java Studio Enterprise 8)'s code generation

    Hi!
    I am using Java Studio Enterprise 8 with NetBeans 4.1 IDE bundled together with it. When trying to create GUI out from NetBeans Form Designer, I don't like the way it generates the code. When I try to use a JTextField, it uses "Fully Qualifed Class Names" (e.g: javax.swing.JTextField) on the code. How do I set NetBeans not to use it but rather use only the class name and generate import lines on top of the code? Also, how do I set it up that it will generate the variable declarations (which is on the uneditable blue portion of the code) on top rather than the default which is placed at the bottom of the class code body. I have tried tweaking the Options menu of this IDE but haven't got any luck...
    Hope you could help, and thanks in advance!

    To address the location of the var decl codegen section (or any codegen location issues), there is a workaround, admittedly, it is a bit tedious.
    Once the form code is generated, as Kris mentioned, open the class in an external editor so that you can edit the generated code.
    Then cut the entire var declaration section along with the begin/end gen-code markers and paste it to the section of the file you desire.
    When you add more components to your form, the codegen will find this section wherever it is and add to it.
    Alternatively, you could just move the non-protected code around the protected within the NB editor, but you would not be able to rearrange the order of the actual code-genned sections.
    craig

  • Need help with a java chat software!!! Anyone pls give ideas

    I need to implement a chat protocol with sockets for my course!!
    As of now i have only got to the simple client server application with sockets and have a user interface with panels.
    How could I proceed...
    How should i use login names and passwords??
    Should i use if else loops to specify :
    various headers like
    login
    pass
    send
    exit
    if you could point out som esite that will be helpful or even a book it would be of great help!!

    Don't use if/else loops, they have this nasty habit of not existing.
    My quarter-pence:
    For passwords, use a map which maps name/hashed password. That way, you'll never actually store the password.

  • Help with a java assignment

    I am stuck on some things and I can't find them in my book so here goes. I need to determine if a string is even or odd and then return letters from that word based on which it is.
    I think i need to use a boolean for the even or odd (not for sure) and an if / else statement for the letters, but i am lost on some of the details. I should have to do some math to choose which letters i return, but not for sure on how to setup the math to use on a string.
    can anybody help point me in the right direction with this
    if you need more info on this let me know and i will try to explain it better.
    thanks

    i mean that I need to determine if the number of letters in a word is even or odd.
    and here is the code the first one is my main class. I hope i did that right on the posting of the code
    package wordstester;
    import javax.swing.JOptionPane;
    * @author christopher izatt
    public class WordsTester {
         * @param args the command line arguments
        public static void main(String[] args) {
                  // prompt the user to enter a string of their choice
          String wordChosen;
          wordChosen = JOptionPane.showInputDialog
              ("Please enter a word of your choice here");
          String middlePart;
          middlePart = Words.getMiddle(wordChosen);
          System.out.println("At the middle of " + wordChosen + " is: "
                     + middlePart);
    package wordstester;
    * @author christopher izatt
    public class Words {
          Gets the middle character or character pair from this word
          when possible.
          @param word a word supplied by the method user
          @return the middle character (if the word length is odd) or
          middle two characters (if it is even), or the empty string if
          the word is empty, or null if it is null.
       public static String getMiddle(String word)
        private boolean word;
    }

  • Need Help with a Java programming exercise.

    I have to Write a program that reads two times in military format (0900, 1730) and prints the number of hours and minutes between two times. Supply your own test program. Here are two sample runs. User inputs are the numbers.
    Please enter the first time: 0900
    Please enter the second time: 1730
    8 hours 30 minutes
    Please enter the first time: 1730
    Please enter the second time: 0900
    15 hours 30 minutes
    Test Program I can write up myself. But the entire constructor I have no idea how to start. This is basic Java Coding. no C++ no importing anything.
    So far this is what I got and I'm sure it's wrong:
    public class TimeInterval
    private double hours;
    private double minutes;
    public TimeInterval(double Time1, double Time2)
    hours =
    minutes =
    }

    tad2382 wrote:
    Jverd,
    I'm guessing that in your early days on this forum you must have spent a lot of time explaining constructors, object creation, etc. Now, after some 40K posts to the forum, you figure newbies should just go and read the documentation. Is that what a lot of veteran posters feel?Perhaps the OP is not aware of the fact the Sun has a good deal of high quality study material published on their website. What's wrong with posting it in a thread? Why should one copy the same thing over and over again? If after reading that tutorial, the OP still has some questions about it, s/he is free to post a follow up question. I am sure that many of the regulars here are more than happy to answer them.
    Also note that the OP's problem description is rather vague. A "I don't know where to start" is IMO best answered by a link to a comprehensive tutorial or a beginners book.
    Being one of the (relatively) novice posters on the forum, I still feel the need to customize posts,Well, by all means: do so.
    trying to see things from the poster's side. Maybe after a few thousand posts, I'll just keep throwing the same documentation at newbies, instead of detailed customized responses, heh.IMO, that's a load of cr@p.

  • Need Help with a Java Question Plz

    Hi
    Could someone help me out with this please?
    I need to know the difference between the two String methods equals and equalsIgnoreCase
    Thanks

    The former tests if the Strings are equal, the latter tests if they're equal, but ignores case...
    I.e. "A".equalsIgnoreCase("a") returns true, among other things...

  • Need Help with my School Assignment - Error Message

    Hey guys,
    I'm doing a school assignment for my Object Oriented Java programing class. Here's the assignment requirements:
    "There are five kinds of flowers, and their associated costs. Create an array of strings that holds the names of these flowers. Create another array that holds the cost of each corresponding flower. Your program should read the name of a flower and the quantity desired by a customer. Locate the flower in the name array and use that index to find the cost per stem in the cost array. Compute and print the total cost of the sale. Write your solution in one class: FlowerCounterArray.
    The solution should implement the following two methods:
    - addOrder(String flowerName, int quantity) to add to the order. This is in addition to reading from the terminal.
    - printTotal() to print out the total cost to the terminal."
    I wrote up some code so far and I want to test it, but I am getting this error: "']' expected" on the newFlower[0] = new FlowerCounterArrays("petunia", 0.50]; line near the end of the code.
    Here's my code:
    public class FlowerCounterArrays {
        private String flowerName;
        private double price;
        public void addOrder(String flowerName, int quantity) {
            for (FlowerCounterArrays flower : newFlower) {
                if (flower.equals(flowerName)) {
                    total = price * quantity;
                    System.out.println("The price for " + quantity + " " + flower + "(s) is " + total);
                else {
                    System.out.println("Unfortunately we do not carry that type of flower here.");
        public void printTotal() {
            System.out.println(total);
        FlowerCounterArrays[] newFlower = new FlowerCounterArrays[5];
        newFlower[0] = new FlowerCounterArrays("petunia", 0.50];
        newFlower[1] = new FlowerCounterArrays("pansy", 0.75);
        newFlower[2] = new FlowerCounterArrays("rose", 1.50);
        newFlower[3] = new FlowerCounterArrays("violet", 0.50);
        newFlower[4] = new FlowerCounterArrays("carnation", 0.80);
    }Thanks for the help guys! Much appreciated!
    Edited by: he4dhuntr on Oct 14, 2008 1:33 PM

    Ok. I'm kind of new to all this, so some stuff I'm not 100% clear on.
    I get what you're saying though. I put the array into the method.
    Although now I get a new errod: "cannot find symbol - constructor FlowerCounterArrays(java.lang.String,double)"
    I get this error on my newFlower[0] = new FlowerCounterArrays("petunia", 0.50); line
    Here's my new code:
    public class FlowerCounterArrays {
        private String flowerName;
        private double price;
        public void addOrder(String flowerName, int quantity) {
            FlowerCounterArrays[] newFlower = new FlowerCounterArrays[5];
            newFlower[0] = new FlowerCounterArrays("petunia", 0.50);
            newFlower[1] = new FlowerCounterArrays("pansy", 0.75);
            newFlower[2] = new FlowerCounterArrays("rose", 1.50);
            newFlower[3] = new FlowerCounterArrays("violet", 0.50);
            newFlower[4] = new FlowerCounterArrays("carnation", 0.80);
            for (FlowerCounterArrays flower : newFlower) {
                if (flower.equals(flowerName)) {
                    total = price * quantity;
                    System.out.println("The price for " + quantity + " " + flower + "(s) is " + total);
                else {
                    System.out.println("Unfortunately we do not carry that type of flower here.");
        public void printTotal() {
            System.out.println(total);
    }Thanks for the help so far!

  • Needed help with updating java code

    Hello all,
    Let me begin by let you know I am not a programmer and I have tried to solve this by reading on the net. I am a network admin so I tech knowledge but no programming.
    I have a webcam sending a Jpg to an FTP site and there I have used an applet called view.class to refresh once a second.
    site:http://70.154.170.253/webcamold.html
    My problems is now that it refreshes the same image over and over. It refreshes the cached image not the new image.
    From reading I suspect that it has to do with the newer version of java (it used to work fine).
    I have tried using JavaCam but same issue it just refreshes cached image. Also image flickers, the applet I am trying to fix was really smooth.
    I have also tried to compile code that I found on this forum but I got error dealing with deprecated code.
    Any help would be greatly appreciated!!!
    Code:
    import java.applet.Applet;
    import java.awt.*;
    import java.io.PrintStream;
    public class View extends Applet
    implements Runnable
    public void init()
    setBackground(Color.white);
    String s = getParameter("refresh");
    if(s == null)
    update = 30;
    else
    try
    update = Integer.parseInt(s);
    catch(Exception _ex)
    update = 30;
    filename = getParameter("picture");
    if(filename == null)
    System.out.println("No filename given as parameter.");
    md = new MediaTracker(this);
    off = createImage(size().width, size().height);
    refreshImage();
    public void paint(Graphics g)
    g.drawImage(off, 0, 0, this);
    public void update(Graphics g)
    paint(g);
    public void refreshImage()
    img = getImage(getDocumentBase(), filename);
    md.addImage(img, 0);
    try
    md.waitForID(0);
    catch(Exception exception)
    exception.printStackTrace();
    Graphics g = off.getGraphics();
    g.drawImage(img, 0, 0, this);
    img.flush();
    public void run()
    while(th != null)
    try
    refreshImage();
    repaint();
    Thread.sleep(update * 1000);
    catch(Exception exception)
    System.out.println("Error when thread was supposed to sleep: " + exception.getMessage());
    public void start()
    if(th == null)
    th = new Thread(this);
    try
    th.start();
    return;
    catch(Exception exception)
    System.out.println("Couldn't start thread: " + exception.getMessage());
    return;
    } else
    return;
    public void stop()
    if(th != null)
    th.stop();
    th = null;
    public void destroy()
    stop();
    public View()
    update = 30;
    Thread th;
    String filename;
    int update;
    Image img;
    Image off;
    MediaTracker md;

    This is compile error free code and regarding your issues i don't think am good at this stuff
    import java.applet.Applet;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Image;
    import java.awt.MediaTracker;
    public class View extends Applet implements Runnable {
         Thread th;
         String filename;
         int update;
         Image img;
         Image off;
         MediaTracker md;
         public void init() {
              setBackground(Color.white);
              String s = getParameter("refresh");
              if (s == null) {
                   update = 30;
              } else {
                   try {
                        update = Integer.parseInt(s);
                   } catch (Exception _ex) {
                        update = 30;
              filename = getParameter("picture");
              if (filename == null) {
                   System.out.println("No filename given as parameter.");
              md = new MediaTracker(this);
              off = createImage(size().width, size().height);
              refreshImage();
         public void paint(Graphics g) {
              g.drawImage(off, 0, 0, this);
         public void update(Graphics g) {
              paint(g);
         public void refreshImage() {
              img = getImage(getDocumentBase(), filename);
              md.addImage(img, 0);
              try {
                   md.waitForID(0);
              } catch (Exception exception) {
                   exception.printStackTrace();
              Graphics g = off.getGraphics();
              g.drawImage(img, 0, 0, this);
              img.flush();
         public void run() {
              while (th != null) {
                   try {
                        refreshImage();
                        repaint();
                        Thread.sleep(update * 1000);
                   } catch (Exception exception) {
                        System.out.println("Error when thread was supposed to sleep: "
                                  + exception.getMessage());
         public void start() {
              if (th == null) {
                   th = new Thread(this);
                   try {
                        th.start();
                        return;
                   } catch (Exception exception) {
                        System.out.println("Couldn't start thread: "
                                  + exception.getMessage());
                   return;
              } else {
                   return;
         public void stop() {
              if (th != null) {
                   th.stop();
                   th = null;
         public void destroy() {
              stop();
         public View() {
              update = 30;
    }

  • Need help with this java thing

    i got a script for virtual keyborad but i don't know much javascript
    so need your help to fit this script to my htmldb application .
    i have page with textare name P2_MESSAGE_DESC
    i put the image near the textarea and i want the textarea to "get" what i type in the keyboard image.
    here is the hava script :
    <SCRIPT language=JavaScript>
    //This var is changed on Unload from talkback to 'false' in order to not generate this onUnload
    var DoUnload = true;
    //var theInputName = opener.document.myform.inputName.value;
    var theInputLength;
    function doInsert(theChar) { 
       opener.document.myform(opener.document.myform.inputName.value).value += theChar;
    function doDelete() {   
      theInputLength = opener.document.myform(opener.document.myform.inputName.value).value.length;       
      if(theInputLength > 0) {   
         if(opener.document.myform(opener.document.myform.inputName.value).value.substring(theInputLength-1,theInputLength)=="\n") {
              opener.document.myform(opener.document.myform.inputName.value).value = opener.document.myform(opener.document.myform.inputName.value).value.substring(0,theInputLength-2);
         } else {
              opener.document.myform(opener.document.myform.inputName.value).value = opener.document.myform(opener.document.myform.inputName.value).value.substring(0,theInputLength-1);
    function doSubmit() {
       //opener.document.myform.submit();
       window.close();
    </SCRIPT>
    <IMG height=159 src="#WORKSPACE_IMAGES#kbd.GIF" width=341 useMap=#HebMap border=0>
    <MAP name=HebMap>
    <AREA shape=RECT coords=272,94,297,120 href="javascript:doInsert('.')">
    <AREA shape=RECT coords=246,94,271,120 href="javascript:doInsert('&#1509;')">
    <AREA shape=RECT coords=220,94,245,120 href="javascript:doInsert('&#1514;')">
    <AREA shape=RECT coords=194,94,219,120 href="javascript:doInsert('&#1510;')">
    <AREA shape=RECT coords=168,94,193,120 href="javascript:doInsert('&#1502;')">
    <AREA shape=RECT coords=142,94,167,120 href="javascript:doInsert('&#1504;')">
    <AREA shape=RECT coords=116,94,141,120 href="javascript:doInsert('&#1492;')">
    <AREA shape=RECT coords=90,94,115,120 href="javascript:doInsert('&#1489;')">
    <AREA shape=RECT coords=64,94,89,120 href="javascript:doInsert('&#1505;')">
    <AREA shape=RECT coords=38,94,63,120 href="javascript:doInsert('&#1494;')">
    <AREA shape=RECT coords=286,67,311,93 href="javascript:doInsert(',')">
    <AREA shape=RECT coords=260,67,285,93 href="javascript:doInsert('&#1507;')">
    <AREA shape=RECT coords=234,67,259,93 href="javascript:doInsert('&#1498;')">
    <AREA shape=RECT coords=208,67,233,93 href="javascript:doInsert('&#1500;')">
    <AREA shape=RECT coords=182,67,207,93 href="javascript:doInsert('&#1495;')">
    <AREA shape=RECT coords=156,67,181,93 href="javascript:doInsert('&#1497;')">
    <AREA shape=RECT coords=130,67,155,93 href="javascript:doInsert('&#1506;')">
    <AREA shape=RECT coords=104,67,129,93 href="javascript:doInsert('&#1499;')">
    <AREA shape=RECT coords=78,67,103,93 href="javascript:doInsert('&#1490;')">
    <AREA shape=RECT coords=52,67,77,93 href="javascript:doInsert('&#1491;')">
    <AREA shape=RECT coords=26,67,51,93 href="javascript:doInsert('&#1513;')">
    <AREA shape=RECT coords=247,40,272,66 href="javascript:doInsert('&#1508;')">
    <AREA shape=RECT coords=221,40,246,66 href="javascript:doInsert('&#1501;')">
    <AREA shape=RECT coords=195,40,220,66 href="javascript:doInsert('&#1503;')">
    <AREA shape=RECT coords=169,40,194,66 href="javascript:doInsert('&#1493;')">
    <AREA shape=RECT coords=143,40,168,66 href="javascript:doInsert('&#1496;')">
    <AREA shape=RECT coords=117,40,142,66 href="javascript:doInsert('&#1488;')">
    <AREA shape=RECT coords=91,40,116,66  href="javascript:doInsert('&#1512;')">
    <AREA shape=RECT coords=65,40,90,66  href="javascript:doInsert('&#1511;')">
    <AREA shape=RECT coords=39,40,64,66 href="javascript:doInsert('\'')">
    <AREA shape=RECT coords=13,40,38,66 href="javascript:doInsert('/')">
    <AREA shape=RECT coords=303,14,328,39 href="javascript:doInsert('0')">
    <AREA shape=RECT coords=277,14,302,39 href="javascript:doInsert('9')">
    <AREA shape=RECT coords=251,14,276,39 href="javascript:doInsert('8')">
    <AREA shape=RECT coords=225,14,250,39 href="javascript:doInsert('7')">
    <AREA shape=RECT coords=199,14,224,39 href="javascript:doInsert('6')">
    <AREA shape=RECT coords=173,14,198,39 href="javascript:doInsert('5')">
    <AREA shape=RECT coords=147,14,172,39 href="javascript:doInsert('4')">
    <AREA shape=RECT coords=121,14,146,39 href="javascript:doInsert('3')">
    <AREA shape=RECT coords=95,14,120,39  href="javascript:doInsert('2')">
    <AREA shape=RECT coords=69,14,94,39   href="javascript:doInsert('1')">
    <AREA shape=RECT coords=13,14,67,39 href="javascript:opener.nextField()">
    <AREA shape=RECT coords=273,40,328,66 href="javascript:doDelete()">
    <AREA shape=RECT coords=78,121,258,147 href="javascript:doInsert(' ')">
    <AREA shape=RECT coords=272,121,327,147 href="javascript:doInsert('\n')">
    </MAP>i just need to figure out the :
    opener.document.myform(opener.document.myform.inputName.value).value += theChar;
    how to change it to my p2_message_desc ?
    thanks

    thanks carl ,
    i changed it to:
    document.getElementById('P2_MESSAGE_DESC').value += theChar;
    and it put me the keyword in the textarea.
    one problem left :-(
    i want it to put the keyword where the cursor is for example
    if i have this sentence in my textarea:
    i love oracle htmldb application
    and cursor is before htmldb word and i enter the word (push the virtual keyboard bottons):
    develope
    the sentence will be:
    i love develope oracle htmldb application .
    now if i do that i'm getting:
    i love oracle htmldb application develope.
    i hope you get my point.
    thanks

  • Need help with a Java-SQL connection

    My classmates and I created a DesktopFrame. Within it are reports that require a connection to an MS Access Database. When a report in an InternalFrame is opened: the SQL command works, there is a connection, and everything goes well on the first run.
    However, when another InternalFrame is opened or when the same InternalFrame is opened the 2nd time, an error occurs. It produces a java.sql.SQLException: General Error.
    Can anyone help me? Thanks in advance.

    Provide more info, maybe even some code segments. (Not all). May be easier to help

Maybe you are looking for

  • Deploy forms applications on 9iAS

    Hi, I am very new to Oracle 9i and our DBA is on leave.... I have following setup Oracle 9i database on Unix (Solaris 2.8) Oracle 9i AS on Unix (Solaris 2.8) Oracle 9i DS on Windows XP. I have developed a small application using 9iDS and am able to d

  • Sapscript & smartform upgrade issue

    Can anyone please let me know the issues faced while upgrading sapscript and smartform in documents like purcchase order,sales order and invoice.

  • Substring Chinese Character

    Hi guys, I'm a newbie to this forum and I just started using PL/SQL again after 2 years. I'm working with oracle form and I have a field with size of VARCHAR2(30). My stuff should work for chinese and latin and I got into trouble when i try to substr

  • How to create custom signal/battery bar using j2me?

    first of all im trying to create the symbian UI from scratch .... but j2me comes with a fixed signal bar ... can i change it ??? second is it possible 2 create the UI using j2me ?? thank u

  • Update memory info failed

    We have an Oracle SQL query which runs in seconds directly on the database but when we put it in InfoView it runs for several minutes. We ran a trace on the query in InfoView and received thousands of lines of this: **WARNING:CCDZMgr:Update memory in