Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
+1 vote
17.3k views
in Computer by (49.9k points)
closed by

Write a program in Java to accept a string in lower case and change the first letter of every word to upper case. Display the new string. 

Sample input: we are in cyber world 

Sample output : We Are In Cyber World

1 Answer

+1 vote
by (48.9k points)
selected by
 
Best answer

import java.io.*; 

import java.util.Scanner; 

class ChangeLetter { 

public static void main(String args[ ]) throws IOException { 

Scanner sc = new Scanner(System.in); 

System.out.print(“Enter String in lowercase:”); 

String str 1 = sc.next( ); strl = “” +strl; 

String str2 = ” “: 

for (int i = 0; i<strl.lenght(); i+ +) {

if(strl ,charAt(i) = = “) { 

str2 = str2 + ” +Character. 

toUpperCase(strl.charAt(i+l)); i+ + ; 

}. 

else str2= str2 + strl.charAt(i); 

System.out.println(str2.trim( )); 

}

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...