Results 1 to 13 of 13

Thread: help help help

  1. #1
    sub-zero is offline Member
    Join Date
    Jan 2009
    Posts
    6
    Rep Power
    0

    Unhappy help help help

    hi guys
    i need help plz:confused:
    i'm taking java course :)

    and without your help i don't think i can solve this so heeeeeeeeeeeeeeeeeelllllllllp me please

    ---------------------------------------
    about average consuming electricity / water

    according to the system chipset.
    We will take the following case in segments of the electricity consumption:
    • less than 1000 k is calculated 2 $
    • Between 1000 and 2000 k k calculated 3.5 $
    • Between 2000 and 3000 k k calculated 6.5 $
    • any consumption is higher than 3000 is calculated 10 $

    Example: The 3500 consumption rate is calculated as follows:
    Price = (1000 * 2.0) + (1000 * 3.5) + (1000 * 6.5) + (500 * 10) = 17000

    Required:
    Writing a program in Java accept the follows:
    Consumption (k)
    Name of the consumer
    And the insertion is for a group of people
    and the insertion end when the introduction of the value indicates to a negative insertion (with the introduction of the consumption of negative value).

    The output would be required as follows:
    1. Name ,consumption, price
    2. The calculation of the average total consumption.
    3. Show the name of the largest consumer.


    write a program based on the 5 of basic instructions (without the use of "for" )
    And the built of simple data only (without the use of
    "tables").


    Example of the implementation of the program:
    (Input)
    500
    Adam
    2000
    Sam
    1500
    Mark
    3500
    David
    -1000
    xxxx
    (End Input)
    (Output)
    Name Consume Price
    Adam 500 1000.0
    Sam 2000 5500.0
    Mark 1500 3750.0
    David 3500 16500.0

    Average = 1875.0
    The name of the Max Consume = [David]

    Example of the implementation of the program:


    500
    Adam
    name consume price
    Adam 500 1000
    2000
    Sam
    name consume price
    Sam 2000 5500
    1500
    Mark
    name consume price
    Mark 1500 3750
    3500
    David
    name consume price
    David 3500 16500
    -1
    xxx
    Average =1875
    The name of Max consume = [David]
    --------------------------------

    that is all of it
    plz guys i'm wating your REPLIES asap
    Last edited by sub-zero; 01-19-2009 at 03:06 AM.

  2. #2
    sub-zero is offline Member
    Join Date
    Jan 2009
    Posts
    6
    Rep Power
    0

    Default

    the Example was suppose to came in Horizontal way but some how after i post it came vertical , anyway i need it to be in the Horizontal view

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    what have you done so far?

  4. #4
    sub-zero is offline Member
    Join Date
    Jan 2009
    Posts
    6
    Rep Power
    0

    Default

    thanks
    Fubarable for replying

    i know that all that i have done so far is all wrong that's why im so depressed



    class
    public static void main (String [] args)

    System.out.println ("Adam");
    int consum = 2000; //

    System.out.println ("Sam");
    int consum = 1500; //

    int max = 1800;
    string nameMax = "";

    if (consum > max) //
    {
    max = consum; //
    nameMax = name; //
    }
    ----
    i know that this the code that i have to use but i don't know how

    int consum = 1; //
    int max = 0;
    string nameMax = "";

    if (consum > max) //
    {
    max = consum; //
    nameMax = name; //
    }

    -----
    System.out.println(Sb+"\t\t"+a+"\t\t"+p);
    System.out.println("Average = "+average);
    System.out.println("The name of the Max Consume = "+"["+maxn+"]");
    Last edited by sub-zero; 01-19-2009 at 03:40 AM.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    is that your code, because if it is, it's missing a lot of stuff such as the class name and curly braces that surround the class and methods, just to name two things.

    If this isn't the code, please post your actual code so we can see it.
    Good luck.

  6. #6
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default hhhmmm...

    Subzero... please don't indicate that you need us to help you fast. We will try to help you as life permits, but your urgency is not our urgency... any help given is volunteer help.
    If that is your best attemp to code the requirements, then you are pretty far from your goal.
    I would suggest to start studying the Java tutorials:
    The Javaô Tutorials
    • You will need to know about loops ("while" loop sounds it would do the job).
    • You will need to study how to get user input (scanner class would be good).

    That should get you started.

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  7. #7
    sub-zero is offline Member
    Join Date
    Jan 2009
    Posts
    6
    Rep Power
    0

    Default

    the class name is -public class average
    and one of my problems is the curly braces i either put too many or forget about putting them
    that is the code , i know i'm complete mess


    the only thing that i seem to know in java is
    System.out.println ("");

    is there a hope that i can do these in 4 hours
    ----
    thanks
    CJSLMAN i start reading The Java™ Tutorials
    Last edited by sub-zero; 01-19-2009 at 04:15 AM.

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    It appears that you're somewhat behind in your Java studies. It may be possible, depending on how smart you are, but 4 hours is a lot to ask for something that would probably require studying for the last few days to weeks.

    If you truly are as lost as you claim, your best bet is to set up tutoring with your teacher.

    Good luck with this.

  9. #9
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default Sorry...

    I'm afraid you are doomed. I don't think you can do it in that timeframe with your current level of knowledge of Java. Try to get an extension. And then study like hell to get up to speed. I will sketch out what I think the flow should be:

    loop while not equal to "quit"
    get client name -> store in arraylist
    get client electricity usage -> Store in arraylist
    end loop
    do calculations
    print results
    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  10. #10
    sub-zero is offline Member
    Join Date
    Jan 2009
    Posts
    6
    Rep Power
    0

    Default

    Hi guys .Iím back
    I managed to postpone the submission, I studied a bitĒ I have exams ď
    And here what Iíve done so far

    -----------------
    import javax.swing.JOptionPane;
    class sub-zero {
    public static void main (String[]args){
    float a; String Sa;
    float b; String Sb;
    float c; String Sc;
    float d; String Sd;
    Sa = JOptionPane.showInputDialog("Input adam: ");
    a = Float.parseFloat(Sa);
    Sb = JOptionPane.showInputDialog("Input sam: ");
    b = Float.parseFloat(Sb);
    Sc = JOptionPane.showInputDialog("Input mark: ");
    c = Float.parseFloat(Sc);
    Sd = JOptionPane.showInputDialog("Input david: ");
    d = Float.parseFloat(Sd);
    }
    }

    -------------

    am i working on the right track here
    where do i put the consumption

  11. #11
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default Question...

    Is the input of consumers fixed? Will it always be Adam, Sam, Mark & David? or could it be Adam, Sam, Mark, David, Billy and Adolf?

    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  12. #12
    sub-zero is offline Member
    Join Date
    Jan 2009
    Posts
    6
    Rep Power
    0

    Default thanks ,CJSL

    it could be ...

    but should i but once the name("Input:the name");
    and once ("Input:the consumption");

  13. #13
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default

    Well, that's up to your requirements... I don't know what is expected of your program. Generally, yes, that is the way to program the inputs: first you ask for the name of the user/consumer and then you would ask for their consumption. This would be done by a for loop and arraylists (it could also be done by a Hashmap, but I won't go there).

    Some thing like (pseudo code):
    Java Code:
    create arraylist for names
    create arraylist for consumption
    while (! name == quit)
    {
    names[i] = ask for name
    consumes [i] = ask for consumption
    }
    Luck,
    CJSL
    Last edited by CJSLMAN; 01-22-2009 at 09:17 AM. Reason: corrected the name of the loop
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •