Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- //Public - могу получить доступ из любой части проекта
- //Static - вызываю как octStringToInt, а не object.octStringToInt()
- //int - return int
- public static int octStringToInt(String s) {
- int answer = Integer.parseInt(s,8);
- return answer;
- }
- public static boolean isNumeric(String s) {
- for (char c : s.toCharArray())
- {
- if (!Character.isDigit(c))
- return false;
- }
- return true;
- }
- public static int countNums(String s) {
- int answer = 0;
- for(String str : s.split(" ")) {
- if(isNumeric(str))
- answer++;
- }
- return answer;
- }
- public static void main(String[] agrs) {
- System.out.println(octStringToInt("777"));
- System.out.println(countNums("The user with the nickname koala757677 this month wrote 3 times more comments than the user with the nickname croco181dile920 4 months ago"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement