0

Help me with this java program please, not accepting any statement and I can't understand the reason

import java.util.*; public class program{ public static void main(){ Scanner sc=new Scanner(System.in); String sent="",word=""; char c=' '; int n=0,l=0,m=0,j=0; System.out.println("Enter the number of sentences which may be greater than equals to one but less than 4"); n=sc.nextInt(); System.out.println("Enter a paragraph with each sentences either terminating with '.' or '?'"); sent=sc.nextLine(); sent=sent.toUpperCase(); l=sent.length(); for(int i=0;i<l;i++){ c=sent.charAt(i); if(c=='.'||c=='?') m+=1; } if(n!=m) System.out.println("The number of sentences typed before is not same with the number"); StringTokenizer st=new StringTokenizer(sent); while(st.hasMoreTokens()){ word=st.nextToken(); j+=1; } System.out.println("Total number of words in the paragraph is:"+j); } }

28th Dec 2021, 5:02 AM
Sunil
1 ответ
+ 4
public static void main(String[] args){ //could be?
28th Dec 2021, 5:52 AM
CGM
CGM - avatar