Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 11 of 11

Thread: Urgent question

  1. #1
    Junior Member
    Join Date
    Oct 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Urgent question

    I need to create a Java program that takes an input a color code in HSV and
    outputs the equivalent RGB code and Vice versa.
    Example:
    If you test on the color RED in RGB:
    Input: (255,0,0)
    Output: (0,100%,100%)
    If you test on the color RED in HSV:
    Input0,100%,100%)
    Output: (255,0,0)


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Urgent question

    You forgot to ask a question.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Oct 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Urgent question

    Quote Originally Posted by KevinWorkman View Post
    You forgot to ask a question.
    I am new to this website do you have an answer to my question or you can help me with that ?!

  4. #4
    Junior Member
    Join Date
    May 2013
    Location
    Charleston SC
    Posts
    21
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default Re: Urgent question

    We don't do the work for you. Please show us what you have tried and let us know what problem you are having at a given point. We are more then happy to help you understand and progress your project.

  5. #5
    Junior Member
    Join Date
    Oct 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Urgent question

    Quote Originally Posted by jbarke12 View Post
    We don't do the work for you. Please show us what you have tried and let us know what problem you are having at a given point. We are more then happy to help you understand and progress your project.
    I dont know If I an right or not here is what I did !



    public class Converter {
    public Converter() {

    }

    public static double[] RGBtoHSV(double r, double g, double b) {
    double h,s,v;

    double min, max, delta;

    min = Math.min(Math.min(r, g), b);
    max = Math.max(Math.max(r, g), b);

    // Operations on V
    v = max;

    delta = max - min;

    // operations on S
    if (max != 0)
    s = delta / max;
    else {
    s = 0;
    h = -1;
    return new double[] { h, s, v };
    }

    // operations on H
    if (r == max)
    h = (g - b) / delta;
    else if (g == max)
    h = 2 + (b - r) / delta;
    else
    h = 4 + (r - g) / delta;

    h *= 60;

    if (h < 0)
    h += 360;

    return new double[] { h, s, v };
    }

    public static void main(String[] args) {

    }

    }

  6. #6
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Urgent question

    When posting code, please use the highlight tags to preserve formatting. You can edit your post to add them.

    What does this code do? Does it do what you expect? What's missing from it?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  7. #7
    Junior Member
    Join Date
    Oct 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Urgent question

    Quote Originally Posted by KevinWorkman View Post
    When posting code, please use the highlight tags to preserve formatting. You can edit your post to add them.

    What does this code do? Does it do what you expect? What's missing from it?
    as I expect from this it should convert from RGB to HSV but but I am not sure if Its Right or not

  8. #8
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Urgent question

    What happened when you ran the code? Does it output what you expect?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  9. #9
    Junior Member
    Join Date
    Oct 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Urgent question

    Quote Originally Posted by KevinWorkman View Post
    What happened when you ran the code? Does it output what you expect?
    Whenever I run the code I get no output and this is the problem!

  10. #10
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 697 Times in 679 Posts

    Default Re: Urgent question

    Please give your threads better titles. Many will skip threads that don't sound interesting or indicate urgency by the OP.

  11. #11
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Urgent question

    You main method is empty, so this program won't do anything. Why do you expect this to output anything?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. [SOLVED] URGENT Array List Question
    By iWaterBuffalo in forum What's Wrong With My Code?
    Replies: 6
    Last Post: May 9th, 2014, 01:43 PM
  2. Need urgent help regarding java word wrap function.. URGENT
    By coldice in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 16th, 2011, 05:43 AM
  3. PLEASE HELP ME .. IS URGENT
    By chela02 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 18th, 2010, 04:37 PM
  4. Need Urgent Help
    By sonai4u in forum Threads
    Replies: 2
    Last Post: February 13th, 2010, 07:24 PM
  5. Replies: 2
    Last Post: May 16th, 2009, 05:23 AM

Tags for this Thread