Create a program called ColorComparer that asks the user for two sets of RGB values (integer values between 0 and 255) for a total of six integers, then creates two different Color objects with the gathered RGB values. Then, compare the two colors to one another using equals(), and return whether the two colors being the same is true or false. For this problem, the program is not expected to know when any of the RGB values are outside of the range of 0 to 255.
(Java Coding Style)
import java.awt.*;
import java.util.Scanner;
public class ColorComparer {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter r g and b for first color: ");
int r1 = in.nextInt(), g1 = in.nextInt(), b1 = in.nextInt();
System.out.print("Enter r g and b for second color: ");
int r2 = in.nextInt(), g2 = in.nextInt(), b2 = in.nextInt();
Color color1 = new Color(r1, g1, b1);
Color color2 = new Color(r2, g2, b2);
if(color1.equals(color2)) {
System.out.println("Both colors are same");
} else {
System.out.println("Both colors are not same");
}
}
}
Create a program called ColorComparer that asks the user for two sets of RGB values (integer...
Create a program called ColorComparer that asks the user for two sets of RGB values (integer values between 0 and 255) for a total of six integers, then creates two different Color objects with the gathered RGB values. Then, compare the two colors to one another using equals(), and return whether the two colors being the same is true or false. For this problem, the program is not expected to know when any of the RGB values are outside of...
3.20 LAB: Remove gray from RGB (C Language) Summary: Given integer values for red, green, and blue, subtract the gray from each value. Computers represent color by combining the sub-colors red, green, and blue (rgb). Each sub-color's value can range from 0 to 255. Thus (255, 0, 0) is bright red, (130, 0, 130) is a medium purple, (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is...
Wrote a program called ExceptionalDivide that asks the user for 2 integer values and displays the quotient of the first value divided by the second value. Make sure the your program reads in the two input values as ints. Your program must catch either of two exceptions that might arise and crash your program java.util.InputMismatchException //wrong data type inputted java.lang.ArithmeticException //divide by zero error Once you catch these exceptions, your program must print out a message explaining what happened and...
Write a program in JAVA that asks the user to enter an integer. Store the integers in an array. Allow for up to 10 integers. When the user enters -1, the program should end. Print the number of integers entered as well as the number of times each integer was entered.
Design a Java program that asks the user to enter an integer number n and then generates an array of that many random points (x, y) with x- and y-coordinates in the range between 0 and 100. After this the program must ask the user to enter two diagonal points (x_1, y_1) and (x_2, y_2) of a rectangle with sides parallel to the coordinate axis (see the image below, where possible pairs of diagonal points are shown in red color)....
3.22 LAB: Remove gray from RGB Summary: Given integer values for red, green, and blue, subtract the gray from each value. Computers represent color by combining the sub-colors red, green, and blue (rgb). Each sub-color's value can range from 0 to 255. Thus (255, 0, 0) is bright red, (130, 0, 130) is a medium purple, (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded...
In a file called First SecondNext.java, write a program that: • Asks the user to enter a string that contains at least five letters. It is OK if your program crashes when the user enters a string with length less than 5. • Stores that string in a variable called s. • Creates a variable called "first", and sets it equal to the first letter of s. • Creates a variable called "second", and sets it equal to the second...
Write a java program that asks the user to enter an integer. The program should then print all squares less than the number entered by the user. For example, if the user enters 120, the program should display 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, and 100.
C++ coding answer
5. Write a program that asks the user for a positive integer value. The program should use a loop to get the sum of all the integers from 1 up to the number entered. For example, if the user enters 50, the loop will find the sum of 1, 2, 3, 4, ... 50. Input Validation: Do not accept a negative starting number.
write a program that asks the user to enter two integers one at a time if the first value is not an integer then do not ask for a second then display both values otherwise print error message stating which value entered was not an integer python