JAVA COLOR CONVERSION PROGRAM - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

JAVA COLOR CONVERSION PROGRAM

javanoob17javanoob17 Posts: 0Member

I need help with this program. i am fairly need to java programming. This is from the introduction to programming in java: An Interdisciplinary Approach.

Color conversion. Several different formats are used to represent color. For example, the primary format for LCD displays, digital cameras, and web pages, known as the RGB format, specifies the level of red (R), green (G), and blue (B) on an integer scale from 0 to 255. The primary format for publishing books and magazines, known as the CMYK format, specifies the level of cyan (C), magenta (M), yellow (Y), and black (K) on a real scale from 0.0 to 1.0. Write a program RGBtoCMYK that converts RGB to CMYK. Take three integers—r, g, and b—from the command line and print the equivalent CMYK values. If the RGB values are all 0, then the CMY values are all 0 and the K value is 1; otherwise, use these formulas:

w = max( r / 255, g / 255, b / 255 ) c = (w - ( r / 255)) / w m = (w - ( g / 255)) / w y = (w - ( b / 255)) / w k = 1 - w

**** I am a visual learner so it is easy for me to see programs and usually get them of course at the beginners level but just having a hard time with the logic please help****

This is my code so far.

import java.util.Scanner;

public class RGBtoCMYK //This is the class, RGBtoCMYK { public static void main(String[] args) { Scanner s = new Scanner (System.in); integers w,c,m,y,k;

        w = max( r / 255, g / 255, b / 255 )
        c = (w - ( r / 255)) / w
        m = (w - ( g / 255)) / w
        y = (w - ( b / 255)) / w
        k = 1 - w



    //

} 

} // end of class RGBtoCMYK

Sign In or Register to comment.