I am having a lot of trouble with this homework java question, could anyone help?

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 CMYKtoRGB.java that converts from CMYK format to RGB format using these mathematical formulas:

whiteredgreenblue=1−black=255×white×(1−cyan)=255×white×(1−magenta)=255×white×(1−yellow)white=1−blackred=255×white×(1−cyan)green=255×white×(1−magenta)blue=255×white×(1−yellow)

Your program must take four double command-line arguments cyan , magenta , yellow , and black ; compute the corresponding RGB values, each rounded to the nearest integer; and print the RGB values

and then there’s a diarrhea of letters and equals signs and no punctuation in sight.
Where… exactly do the line breaks go in that block? Why are there whites and blacks in there when CMYK and RGB do not feature ‘white’?

What part of the problem are you having trouble with, and what code have you written so far?

This forum doesn’t deal with Java. It deals with a completely different language called JavaScript.

I recommend that you seek out assistance from a different place that knows something about Java.

Topic has been moved to General Web Dev. Thanks @Mittineague

I would hazard a guess that it’s something like:

white = 1 - black
red = 255 × white × (1−cyan)

Now we just need someone that knows something about Java instead of JavaScript.

You need to declare your variables before you use them, eg:

double cyan, magenta, yellow, black;

and you can try your code out here: https://ideone.com/ideone/Index/submit/

Maybe i’m more psychic in the mornings before my brain wakes up. That or the aliens are talking louder in my head.

Also Paul.

whiteredgreenblue=1−black=255×white×(1−cyan)=255×white×(1−magenta)=255×white×(1−yellow)white=1−blackred=255×white×(1−cyan)green=255×white×(1−magenta)blue=255×white×(1−yellow)

I’m guessing this was a table that you tried to copy and paste that wrote something like…

white red green blue
=1-black =255*white*1-cyan =255*white*(1−magenta) =255*white*(1−yellow)

Which would be the standard formulae for converting CMYK to RGB (though most of the time they dont bother defining white, and just say 255*(1-K)*(1-WhateverColor)

So, you’ve got the maths.

You presumably have some basic skill at producing a java script. (Note: Not a JavaScript. As you’re in school, and either will take or have recently taken a standardized test that requires them, an analogy is in order: Java is to JavaScript as pen is to penguin.)

Show us what you’ve done, and we can help you. “Do this for me” is going to get no response.

white = 1- black
red = 255xwhitex(1-cyan)
green= 255xwhite(1-magenta)
blue=255×white×(1−yellow)

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.