2. Recursion- Find sum of digits of a number using recursion.
importjava.util.Scanner;publicclassSumDigits{publicstaticintsumOfDigits(intn){if(n==0)return0;returnn%10+sumOfDigits(n/10);}publicstaticvoidmain(String[]args){Scannersc=newScanner(System.in);System.out.print("Enter a number: ");intnum=sc.nextInt();System.out.println("Sum of digits: "+sumOfDigits(num));}}
3. Get numbers until 'q', sum & count
importjava.util.Scanner;publicclassSumCount{publicstaticvoidmain(String[]args){Scannersc=newScanner(System.in);intsum=0,count=0;while(true){Stringinput=sc.nextLine();// e.g. 10,wString[]parts=input.split(",");intnumber=Integer.parseInt(parts[0]);charch=parts[1].charAt(0);sum+=number;count++;if(ch=='q')break;}System.out.println("Count: "+count);System.out.println("Sum: "+sum);}}
4. Get numbers, validate, print min & max
importjava.util.*;publicclassMinMaxValidation{publicstaticvoidmain(String[]args){Scannersc=newScanner(System.in);List<Integer>nums=newArrayList<>();while(true){intn=sc.nextInt();if(n<0){System.out.println("Error: Negative number not allowed");continue;}if(n>999){System.out.println("Error: Number with more than 3 digits not allowed");continue;}nums.add(n);if(nums.size()==5)break;// stop after 5 numbers for example}System.out.println("Numbers: "+nums);System.out.println("Min: "+Collections.min(nums));System.out.println("Max: "+Collections.max(nums));}}
CREATETABLEstudents(idINTPRIMARYKEY,nameVARCHAR(50),genderVARCHAR(10),classINT);CREATETABLEmarks(idINT,tamilINT,engINT,mathsINT,scienceINT,historyINT,FOREIGNKEY(id)REFERENCESstudents(id));-- Create Students tableCREATETABLEStudents(idINTPRIMARYKEY,nameVARCHAR(50),genderVARCHAR(10),classINT);-- Create Marks tableCREATETABLEMarks(idINTPRIMARYKEY,tamilINT,engINT,mathsINT,scienceINT,historyINT);-- Insert example dataINSERTINTOStudentsVALUES(1,'Vicky','Male',10);INSERTINTOMarksVALUES(1,45,50,60,55,48);-- Total marks per studentSELECTs.id,s.name,(m.tamil+m.eng+m.maths+m.science+m.history)AStotalFROMStudentssJOINMarksmONs.id=m.id;-- Count pass students (class 10, pass mark 40)SELECTCOUNT(*)FROMStudentssJOINMarksmONs.id=m.idWHEREs.class=10ANDm.tamil>=40ANDm.eng>=40ANDm.maths>=40ANDm.science>=40ANDm.history>=40;
Computer Science Engineering student passionate about software development. Currently exploring Java, PSQL, , and web development. Always eager to learn and
answer all of them—
1.get the three no from the user and find the 2nd maximum
2.recursion—sum of digits
3.get the no from the user stope when enter the 'q' and sum of no and count of no example
10,w,12,r,34,q
count -3
sum-56
4.get the no from the user
—print all them
— min
—max
—show error if >3 digits
—show error if negative
5.animal,dog,human
—method whoami if animal obj call — "animal"dog,human
—-if animal obj call — "animal"
—-if dog obj call — "dog"
—if human obj call — "human"
6.get the radius of circle from the user and found the diameter and area
7-13 answer minimum 2
7 .,8 .students ,marks table
in students
id | name | male\female |class
some datas
in marks table
id | tamil |eng|maths|science| history
some datas
write a sql commant to create a table both
find the total of each students
3.add new values to both(insert new row)
4.for 10 class - pass mark-40
for 8th class pass mark is 35
count the pass students
9.html page to crete a students table
get the students mark and validate it each fieads should not be empty
get the user input and write them on the file
12.read the file and count of line,char,words
create a class stack data structure and create the methods peek ,pop,push and thiere corresponding logics
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Top comments (1)
answer all of them—
1.get the three no from the user and find the 2nd maximum
2.recursion—sum of digits
3.get the no from the user stope when enter the 'q' and sum of no and count of no example
10,w,12,r,34,q
count -3
sum-56
4.get the no from the user
—print all them
— min
—max
—show error if >3 digits
—show error if negative
5.animal,dog,human
—method whoami if animal obj call — "animal"dog,human
—-if animal obj call — "animal"
—-if dog obj call — "dog"
—if human obj call — "human"
6.get the radius of circle from the user and found the diameter and area
7-13 answer minimum 2
7 .,8 .students ,marks table
in students
id | name | male\female |class
some datas
in marks table
id | tamil |eng|maths|science| history
some datas
9.html page to crete a students table