id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

zbaharav@kehillah.org quiz1-logic > colorNumber
prev  |  next  |  chance

Given a number between 1 and 100, return a string containing the color of the number. The color of a number is determined by the following rules. A color is "Red" if it is divisible only by 3 and not by 5. A number is "Yellow" if it is divisible by 5 and not by 3. A number is "Orange" if it divisible by both 3 and 5, and is "Black" if it is not divisible by either 3 or 5. (Credit to Oren).


colorNumber(2) → "Black"
colorNumber(6) → "Red"
colorNumber(10) → "Yellow"

...Save, Compile, Run (ctrl-enter)

public String colorNumber(int n) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 100

Copyright Nick Parlante 2017 - privacy