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:");
Pronic Number || Program ICSE Class X
Write a program to input a positive number and check and print whether it is a Pronic number or not.
(Pronic number is a number which can be written as product of two consecutive integers)
Example:
12 = 3 x 4
42 = 6 x 7
20 = 4 x 5
ENTER A POSITIVE INTEGER:
classPronicNumber:
defpronicRepresentation(self):
print(self.__number," is a Pronic Number. ",self.__number," = ",self.__index," x ",(self.__index+1))
defisPronic(self):
i = 1
while (i*(i+1) <= self.__number):
if(i*(i+1) == self.__number):
self.__flag = True
self.__index = i
break
i +=1
return(self.__flag)
def__init__(self,n):
self.__number = n
__number = 0
__index = -1
__flag = False
n = int(input("Enter a positive integer."))
obj = PronicNumber(n)
if(obj.isPronic()):
obj.pronicRepresentation()
else:
print(n," is not a Pronic Number.")
importjava.util.Scanner;
publicclassICSEJava {
publicstaticvoidmain(String[] args) {
intn;
Scannerin = newScanner(System.in);
System.out.println("Enter a positive integer:");
n = in.nextInt();
PronicNumberobj = newPronicNumber(n);
if(obj.isPronic())
obj.pronicRepresentation();
else
System.out.println(n+" is not a Pronic Number");
in.close();
}
}
classPronicNumber {
publicvoidpronicRepresentation() {
System.out.println(number+" is a Pronic Number. "+number+" = "+index+" x "+(index+1));