Skip to content

Easy challenges - part 2 #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Aug 16, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simple Evens
  • Loading branch information
ardallie committed Aug 15, 2021
commit 4371d6d1b1f08f675729ebfe105411eb4bb77a9b
43 changes: 0 additions & 43 deletions src/easy/LongestWord.java

This file was deleted.

40 changes: 40 additions & 0 deletions src/easy/SimpleEvens.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package easy;

/**
* Have the function SimpleEvens(num) check whether
* every single number in passed in parameter is even.
* If so, return the string true, otherwise return the string false.
* For example: if num is 4602225 your program should
* return the string false because 5 is not an even number.
*/
public class SimpleEvens {

/**
* Simple Evens function.
*
* @param num input number
* @return "true" if a number is even
*/
private static String simpleEvens(Integer num) {
String[] digits = num.toString().split("");
for (String digit : digits) {
if (Integer.parseInt(digit) % 2 != 0) {
return "false";
}
}
return "true";
}

/**
* Entry point.
*
* @param args command line arguments
*/
public static void main(String[] args) {
String result1 = simpleEvens(222252);
System.out.println(result1);
String result2 = simpleEvens(228);
System.out.println(result2);
}

}
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy