좋아, 여기 내 딜레마가있다. 불행히도 Java 선생님은 수업 시간에 프로젝트를 시작하는 방법을 가르치지 않으며 프로그램을 시작하기위한 정보를 찾을 수있는 곳을 알려주지 않습니다. 이것이 제 첫 프로그래밍 과정이므로 여전히 몇 가지를 배우려고 노력하고 있습니다.
그래서 요점에 도달하자 그는 다음과 같이 보이기를 원합니다.
이 프로그램은 Ben Barcomb이 작성했습니다.
문자열 입력 : 알래스카
A의 수 : 3
// 프로그램 종료
그게 다입니다. 어디서부터 시작해야할지 모르겠어요. 어떤 도움이라도 대단히 감사하겠습니다! 이것이 제가 지금 가지고있는 것입니다. 프로그램은 내가 알래스카에 들어가면 끝납니다.
import java.util.Scanner;
public class P4_BenjaminBarcomb
{
public static void main(String[] args)
{
System.out.println("This program is written by Benjamin Barcomb\n");
Scanner kb = new Scanner(System.in);
int counter = 0;
System.out.print("Enter a String: ");
String word = kb.next();
for (int i = 0; i < word.length(); i++) {
if (word.substring(i, i+1).equalsIgnoreCase("a"))
counter++;
}
}
}
예는 다음과 같습니다.
import java.util.Scanner;
public class Junk {
public static void main(String[] args) {
Scanner Keyboard = new Scanner(System.in);
System.out.print("Enter a String: ");
String str = Keyboard.nextLine();
for (int i = 0; i < str.length(); i++){
if (str.substring(i, i+1).equalsIgnoreCase("a")){
count++;
}
}
System.out.println("Number of A: "+count);
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다