JAVA, Python, C++ and C programs for students. Here you will also find solutions to boards papers of ISC Computer Science Practical and CBSE Computer Science. ISC and ICSE JAVA PROGRAMS
Pronic Number || Program ICSE Class X
Write a program 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.
ENTER A STRING IN LOWER CASE:
flag = False
while (flag == False):
msg = str(input("Enter a string in lower case:"))
if(msg.islower() == False):
print("Every character must be in lower case, try again:")
flag = False
else:
flag = True
outputmsg = []
outputmsg.append(msg[0].upper())
forkinrange (1,len(msg)):
if (msg[k-1] == ' '):
outputmsg.append(msg[k].upper())
else:
outputmsg.append(msg[k])
string = ""
foriinrange (len(outputmsg)):
string += outputmsg[i]
print(string)
importjava.util.*;
publicclassICSEJava {
publicstaticvoidmain(String[] args) {
Stringinput;
booleanflag;
char[] output;
Scannerin = newScanner(System.in);
do {
System.out.println("Enter a string in lower case:");
input = in.nextLine();
flag = false;
for (inti = 0; i < input.length(); i++) {
if (input.charAt(i) >= 65 && input.charAt(i) <= 90) {
System.out.println("Every character must be in lower case, try again:");
No comments:
Post a Comment