Blue___
코딩배우는 학생🌎
Blue___
전체 방문자
오늘
어제
  • 코딩배우는 학생🧀 (242)
    • Algorithms (145)
      • BOJ[Java] (107)
      • Programmers[Java] (32)
      • Coding_Contest (3)
    • Web (22)
      • .NET Core C# (2)
      • Java (1)
      • Oracle SQL (7)
      • Web-ProJect (3)
      • Error처리 (1)
      • Web지식 (4)
      • Javascript (1)
      • Vue (3)
    • Git (4)
    • Java_beginner(Repl.it) (55)
      • Auto-Graded-Course(AP CS A) (54)
    • 프로젝트 직딩일기 (3)
    • Hanyang_Assignment (0)
    • 이모저모 (4)
      • 잡담 (1)
      • 2021 오픈소스 컨트리뷰터 아카데미 (1)
      • DDD - 6기! (1)
    • 북리뷰 (1)
      • 리팩토링 2판 (1)
      • 클린코드 (0)

블로그 메뉴

  • 🐰GITHUB
  • ☘️포트폴리오
  • 🌸MBC개발_투표 2022
  • 🍭MBC_APP

공지사항

인기 글

태그

  • java basic
  • 레플릿
  • 코딩배우는 학생
  • 프로그래밍
  • programmers
  • Java
  • 코딩
  • 알고리즘
  • AP CS A
  • coding
  • REPL
  • algorithm
  • auto-graded course
  • 백준
  • 프로그래머스
  • 코딩배우는학생
  • Bakjoon
  • repl.it
  • 자바
  • Java tutorial

최근 댓글

최근 글

티스토리

hELLO
Blue___

코딩배우는 학생🌎

054 - Accumulator Method String Practice 2
Java_beginner(Repl.it)/Auto-Graded-Course(AP CS A)

054 - Accumulator Method String Practice 2

2019. 12. 26. 22:19

Write a method header on line two with the following specs:

Returns:

a String

Name:

thirdLetter

Parameters:

a String called s

 

Then complete the method by programming the following behavior

Returns every 3rd letter of the String s, starting the first letter. See below examples.

 

Examples:

  • thirdLetter("hello there") ==> "hltr"
  • thirdLetter("technology") ==> "thly"

Solution

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class Main {
    public static String thirdLetter(String s)
    {
        String result=String.valueOf(s.charAt(0));
        for(int i=1;i<s.length();i++) {
            if(i%3==0) {
                result+=s.charAt(i);
            }
        }
        return result;
    }
    
    //test case below (dont change):
    public static void main(String[] args){
        System.out.println(thirdLetter("hello there")); //"hltr"
        System.out.println(thirdLetter("technology")); //"thly"
    }
}
 
 

 

반응형
저작자표시

'Java_beginner(Repl.it) > Auto-Graded-Course(AP CS A)' 카테고리의 다른 글

056 - Accumulator Method String Practice 4  (0) 2019.12.26
055 - Accumulator Method String Practice 3  (0) 2019.12.26
053 - Accumulator Method String Practice 1  (0) 2019.12.26
052 - Accumulator Method Challenge 2 (optional)  (0) 2019.12.26
051 - Accumulator Method Challenge 1 (optional)  (0) 2019.12.26
    'Java_beginner(Repl.it)/Auto-Graded-Course(AP CS A)' 카테고리의 다른 글
    • 056 - Accumulator Method String Practice 4
    • 055 - Accumulator Method String Practice 3
    • 053 - Accumulator Method String Practice 1
    • 052 - Accumulator Method Challenge 2 (optional)
    Blue___
    Blue___
    완전 연소한 불은 재를 남기지않는다 : 코딩배우는학생 🌎

    티스토리툴바