Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
// user input:
String number = "1345778101";
String sOdd = ("[13579]");
String sNull = ("0");
String mOdd = number.replaceAll (sOdd, "");
String mNull = number.replaceAll (sNull, "");
int nulls = number.length () - mNull.length ();
int evens = number.length () - mOdd.length () - nulls;
int odds = number.length () - (nulls + evens);
// ...
switch (input.charAt (i))
{
case '0': ++nulls; break;
case '2':
case '4':
case '6':
case '8': ++evens; break;
// if no '-' or '.' is in the number
default : ++odds;
}
public static void oddEvenNull_sw (String input)
{
int evens = 0, odds = 0, nulls = 0;
for (int i = 0, max = input.length (); i < max; ++i)
{
switch (input.charAt (i))
{
case '0': ++nulls; break;
case '2':
case '4':
case '6':
case '8': ++evens; break;
// if no '-' or '.' is in the number
default : ++odds;
}
}
System.out.println ("odd: " + odds + "\teven: " + evens + "\tnull: " + nulls);
}
public static void main (String args[])
{
oddEvenNull_sw ("678900479");
}