java - I am new to programming and need to store the below input in one array. Any suggestions? -


below code working with. need store input in array , im pretty lost!

package code.simpleinput; import edu.cmu.ri.createlab.terk.robot.finch.finch; import java.util.scanner;  public class ledsetter     {     private static scanner sc;  public static void main(final string[] args)     {     // instantiating finch object     finch myfinch = new finch();     sc = new scanner(system.in);      // providing instructions user      system.out.println("enter red, green, , blue intensity led (values 0 255)");      // reading in 3 integers     system.out.print("red: <=200 ");     int red = sc.nextint();     system.out.print("green: <=250 ");     int green = sc.nextint();     system.out.print("blue: <=250 ");     int blue = sc.nextint();      /* potential improvement here - check user input make sure in range (0-255) */      // setting led      system.out.println("thanks, beak glow 8 seconds according specifications");      myfinch.setled(red,green,blue);     myfinch.sleep(8000);      // end program finch.quit()      myfinch.quit();     system.exit(0);     } } 

if going have 3 int values in array, then

int[] inputs = new int[3]; ... ...    sc = new scanner(system.in);     // providing instructions user     system.out.println("enter red, green, , blue intensity led (values 0 255)");     // reading in 3 integers     system.out.print("red: <=200 ");     int red = sc.nextint();     inputs[0] = red; system.out.print("green: <=250 ");     int green = sc.nextint();     inputs[1] = green;     system.out.print("blue: <=250 ");     int blue = sc.nextint();       inputs[2] = blue; 

hope helps!


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -