Professional Documents
Culture Documents
Assessment
Assessment
Source Code
import java.util.Scanner
public Question1() {
char a = input.next().charAt(0);
System.out.println("The character '" + a + "' occurences in \"" + str + "\" is : " + count(str, a));
input.close();
int count = 0;
if (str.isEmpty()) {
return 0;
} else {
if (str.charAt(0) == a) {
++count;
}
Sample Output
Question 2
Source Code
import java.util.Scanner;
public Question2() {
int n = input.nextInt();
printChar(n, charToPrint);
input.close();
if (n > 0) {
System.out.print(charToPrint);
System.out.println();
printChar(n - 1, charToPrint);
}
Sample Output