[Solved]Java Homework Problems Question 1 Program Used Count Number Occurrences Char W String Modi Q37135416
Java Homework Problems:
Question 1:
The program is used to count the number of occurrences of thechar ‘w’ in the string.
– Modify the program to …
• Resolve the syntax error
• Print the count of char ‘w’
– Expected Output:
• Number of w : 3
public class CountChar {
public static void main(String[] args) {
String str =”www.oracle.com”;
int max =str.length();
int count = 0;
// if (str.charAt(i) != ‘w’)
// continue;
count++;
System.out.println(“Counting w : ” + count );
}
}
=========================================================
Question 2:
Use a while loop and break statement.
• Implement the following:
– Accept 10 numbers from the user.
– Compute the sum of the numbers entered.
– When 0 is entered, the program must exit and display the sumof the numbers.
import java.util.Scanner;
public class ComputeSum {
public static void main(String[] args) {
}
}
Expert Answer
Answer to Java Homework Problems: Question 1: The program is used to count the number of occurrences of the char ‘w’ in the st… . . .
OR

