Latest topics | » Nitration of aniline - IIT JEE 2018 Advanced - solved Fri Jun 08, 2018 2:34 am by adianadiadi » Diamagnetic - Paramagnetic - Ni(CO)4, [Ni(CN)4]2- and [NiCl4Fri Apr 06, 2018 1:05 am by adianadiadi » IIT JEE chemistry solved interactive question paperSun Oct 29, 2017 12:11 pm by adianadiadi » IIT JEE 2015 SOLVED QUESTION PAPERWed Oct 19, 2016 1:44 pm by adianadiadi » IIT JEE chemistry solved questionsSat Jul 18, 2015 6:15 pm by adianadiadi » General Description of Chinese Market for Foaming Agent ADC Fri May 09, 2014 2:09 pm by happybaicaitou » How to get Lowest Cost MBBS Admission?Mon Feb 24, 2014 6:39 pm by MENTOR 2014 » girl boy vashikaran specialist agori baba ji +91-9461165Tue Jan 21, 2014 6:00 pm by krshastri » STRONG LOST LOVE SPELL +91-9461165176Tue Jan 21, 2014 6:00 pm by krshastri |
feeds | |
|
Search if you can't find it here
| I will post several porgrams today between 9:00 to 12:00 | |
| |
Author | Message |
---|
saif Active member
| Subject: I will post several porgrams today between 9:00 to 12:00 Tue Feb 23, 2010 9:54 pm | |
| I will post several porgrams today between 9:00 to 12:00 |
| | | diptojit Active member
| Subject: Re: I will post several porgrams today between 9:00 to 12:00 Tue Feb 23, 2010 10:22 pm | |
| Let me begin plzzz Here's the program for the ISC 2010 sample paper Q1
import java.io.*; class ISC_sample_2010 { int leap(int a)// checks if leap year or not {int lp=0; if(a%100==0) { if(a%400==0) {lp=1; } } else { if(a%4==0) { lp=1; } } return(lp); } void main()throws IOException { InputStreamReader read=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(read); String m[]={"JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"}; int n[]={31,28,31,30,31,30,31,31,30,31,30,31}; String str,str1="",str2="",str3="",t="";int n2,n1,k=0;String mnth=""; System.out.println("Enter 6 digit number"); str=in.readLine(); str3=str3+(str.charAt(4))+(str.charAt(5));// takes year str2=str2+str.charAt(2)+str.charAt(3);// takes month str1=str1+str.charAt(0)+str.charAt(1);// takes day if(leap(Integer.parseInt(str3))==1) { n[1]=29;} n2=Integer.parseInt(str2); if(n2>12||n2<1) { k=1;}// making k=1 if Invalid date. else { mnth=m[n2-1];}// finds month n1=Integer.parseInt(str1); if(n1>n[n2-1]||n1<1) { k=1;} if(k!=1) { if(str.charAt(1)=='1')// checking for special 2nd digit case { t="st";} else if(str.charAt(1)=='2') { t="nd";} else if(str.charAt(1)=='3') { t="rd";} else { t="th";} System.out.println(n1+t+" "+mnth+","+str3); System.out.println("VALID DATE"); } if(k==1) { System.out.println("INVALID DATE"); } } } |
| | | diptojit Active member
| Subject: Re: I will post several porgrams today between 9:00 to 12:00 Tue Feb 23, 2010 10:24 pm | |
| and here's the program for the ISC sample paper 2010 Q3 on String
import java.io.*; class sample_2010_sentence { int vow(String e)// checks if 'e' begins with vowel { char d=e.charAt(0); if((d=='a')||(d=='e')||(d=='i')||(d=='o')||(d=='u')||(d=='A')||(d=='E')||(d=='I')||(d=='O')||(d=='U')) { return 1;} else {return 0;} } void main()throws IOException { InputStreamReader read=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(read); String a[]=new String[50]; String vo[]=new String[50]; int i; for(i=0;i<50;i++) { a[i]="";vo[i]=""; }// REMEMBER TO NEVER KEEP A STRING ARRAY uninitialized as it stores null otherwise String s,st="",st1="",str="",f;int ln,sen=0,j,k=0,r,h,t=0;char ch;int q=0; System.out.println("Enter sentences"); s=in.readLine(); ln=s.length(); for(i=0;i<ln;i++) { ch=s.charAt(i); if(ch=='.'||ch==','||ch=='!'||ch=='?') { sen++;} } String b[]=new String[sen]; for(i=0;i<ln;i++) { ch=s.charAt(i); if(ch!='.'&&ch!=','&&ch!='!'&&ch!='?') { st=st+ch;} else { b[k]=st+ch; k++;st=""; } } for(i=0;i<sen;i++) { str=b[i]; for(j=0;j<str.length();j++) { ch=str.charAt(j); if(ch!=' '&&ch!='.'&&ch!=','&&ch!='!'&&ch!='?') { st1=st1+ch;} else { a[t]=st1;t++; st1=""; } } for(h=0;h<50;h++) { for(r=h;r<50;r++) { if(a[r].length()!=0&&a[h].length()!=0) { if(a[h].compareTo(a[r])>0) { f=a[h]; a[h]=a[r]; a[r]=f; } } } } for(h=0;h<50;h++) { if(a[h].length()!=0) { System.out.print(a[h]+" "); if(vow(a[h])==1) { vo[q]=a[h]; q++; } } a[h]=""; } t=0; System.out.print(str.charAt(str.length()-1)+" "); } System.out.println(); System.out.println("VOWELS :"); for(i=0;i<50;i++) { if(vo[i].length()!=0) { System.out.print(vo[i]+",");} } } }
|
| | | diptojit Active member
| Subject: Re: I will post several porgrams today between 9:00 to 12:00 Tue Feb 23, 2010 10:26 pm | |
| Here's the ISC 2008 program on smith numbers..
// ISC 2008 Q1 Smith number import java.io.*; class ISC_2008_smith_number { int i; int sum(int a)// returns sum of digits of a { int dig,sum=0; int n=a; while(n!=0) { dig=n%10; n=n/10; sum=sum+dig; } return(sum); } int prime(int b)// checks whether prime or not { int c=0; for(i=2;i<b;i++) { if(b%i==0) { c=1; } } return(c);// returns 0 if prime } int prime_fact(int t)// returns prime factor of t { int h,fact=t; for(i=2;i<=t;i++)// 1 not considered prime factor { if(t%i==0) { h=prime(i); if(h==0) { fact=i; } } } return(fact); } void main()throws IOException // main method { InputStreamReader read=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(read); int na,na1,k,g=0,s=0,k1;int z[]=new int[20]; System.out.println("Enter number"); na=Integer.parseInt(in.readLine()); na1=na; while(na1!=1) { k=prime_fact(na1); z[g]=k;// stores prime factors of na1 in array g[] g++; na1=na1/k; } for(i=0;i<z.length;i++)// z.length finds length of array z[] { k1=sum(z[i]); s=s+k1; }// finds out sum of digits of prime factors int s1=sum(na);// finds sum of digits of input number if(s==s1) { System.out.println("SMITH Number"); } else { System.out.println("NOT SMITH Number"); } } } |
| | | saif Active member
| Subject: Re: I will post several porgrams today between 9:00 to 12:00 Wed Feb 24, 2010 12:24 am | |
| Thanks for posting it here i am currently making Spiral with my own logic.... |
| | | Sponsored content
| Subject: Re: I will post several porgrams today between 9:00 to 12:00 | |
| |
| | | | I will post several porgrams today between 9:00 to 12:00 | |
|
Page 1 of 1 | |
| Permissions in this forum: | You cannot reply to topics in this forum
| |
| |
| |