a program asking the user to unscramble the scrambled word
TRANSCRIPT
![Page 1: A Program Asking the User to Unscramble the Scrambled Word](https://reader035.vdocuments.mx/reader035/viewer/2022062513/557210cc497959fc0b8db0d4/html5/thumbnails/1.jpg)
1. A program asking the user to unscramble the scrambled word.
FRAME:
![Page 2: A Program Asking the User to Unscramble the Scrambled Word](https://reader035.vdocuments.mx/reader035/viewer/2022062513/557210cc497959fc0b8db0d4/html5/thumbnails/2.jpg)
CODING:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
char s;
String sword, nword;
int i=0,l,j,k;
t1.setText("");
t2.setText("");
sword=t3.getText();
l=sword.length();
if(l%3==0)
{k=2;}
else
{k=3;}
while(t1.getText().length()<=l)
{s=sword.charAt(i);
t1.setText(t1.getText() + s);
i+=k;
if(i>l)
{i=i-l;
}
}
for(j=0; j<=50; j++)
{l1.setSelectedIndex(j);
nword=(String)l1.getSelectedValue();
![Page 3: A Program Asking the User to Unscramble the Scrambled Word](https://reader035.vdocuments.mx/reader035/viewer/2022062513/557210cc497959fc0b8db0d4/html5/thumbnails/3.jpg)
if( nword.equals(sword))
{l1.setSelectedIndex(j+1);
t4.setText((String)l1.getSelectedValue());
}
}
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int i,j;
String s,t;
t=t2.getText();
for(i=0; i<=20; i++)
{l1.setSelectedIndex(i);
s=(String)l1.getSelectedValue();
if(s.equals(t3.getText()))
{break;}
}
l1.setSelectedIndex(i-1);
s=(String)l1.getSelectedValue();
if(t.equals(s))
{JOptionPane.showMessageDialog(null, "You are Great. You are right at your point");}
else
{JOptionPane.showMessageDialog(null, "You Lose. You got to learn more.");}
}
![Page 4: A Program Asking the User to Unscramble the Scrambled Word](https://reader035.vdocuments.mx/reader035/viewer/2022062513/557210cc497959fc0b8db0d4/html5/thumbnails/4.jpg)
RUN-TIME VIEW:
![Page 5: A Program Asking the User to Unscramble the Scrambled Word](https://reader035.vdocuments.mx/reader035/viewer/2022062513/557210cc497959fc0b8db0d4/html5/thumbnails/5.jpg)
On Clicking New Word(jButton2):
![Page 6: A Program Asking the User to Unscramble the Scrambled Word](https://reader035.vdocuments.mx/reader035/viewer/2022062513/557210cc497959fc0b8db0d4/html5/thumbnails/6.jpg)
On clicking Guess(jButton 2):
In case , the answer is right:
![Page 7: A Program Asking the User to Unscramble the Scrambled Word](https://reader035.vdocuments.mx/reader035/viewer/2022062513/557210cc497959fc0b8db0d4/html5/thumbnails/7.jpg)
In case the answer is wrong:
![Page 8: A Program Asking the User to Unscramble the Scrambled Word](https://reader035.vdocuments.mx/reader035/viewer/2022062513/557210cc497959fc0b8db0d4/html5/thumbnails/8.jpg)
On again clicking New Word(jButton2):
![Page 9: A Program Asking the User to Unscramble the Scrambled Word](https://reader035.vdocuments.mx/reader035/viewer/2022062513/557210cc497959fc0b8db0d4/html5/thumbnails/9.jpg)
2. A program to check the number of occurrence of every alphabet before it.
FRAME:
![Page 10: A Program Asking the User to Unscramble the Scrambled Word](https://reader035.vdocuments.mx/reader035/viewer/2022062513/557210cc497959fc0b8db0d4/html5/thumbnails/10.jpg)
CODING:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int c, l;
char a, ch;
String w,m;
t2.setText("");
w=t1.getText();
l=w.length();
for(int i=0; i<=l; i++)
{c=0;
a=w.charAt(i);
for(int j=i; j<=l; j++)
{if(w.charAt(j) == a)
{c++;
}
t2.append(w.charAt(j) + "-" + c + "\n");
}
}
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
t1.setText(null);
t2.setText(null);
![Page 11: A Program Asking the User to Unscramble the Scrambled Word](https://reader035.vdocuments.mx/reader035/viewer/2022062513/557210cc497959fc0b8db0d4/html5/thumbnails/11.jpg)
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.exit(0);
}
![Page 12: A Program Asking the User to Unscramble the Scrambled Word](https://reader035.vdocuments.mx/reader035/viewer/2022062513/557210cc497959fc0b8db0d4/html5/thumbnails/12.jpg)
RUN-TIME VIEW:
![Page 13: A Program Asking the User to Unscramble the Scrambled Word](https://reader035.vdocuments.mx/reader035/viewer/2022062513/557210cc497959fc0b8db0d4/html5/thumbnails/13.jpg)
![Page 14: A Program Asking the User to Unscramble the Scrambled Word](https://reader035.vdocuments.mx/reader035/viewer/2022062513/557210cc497959fc0b8db0d4/html5/thumbnails/14.jpg)
![Page 15: A Program Asking the User to Unscramble the Scrambled Word](https://reader035.vdocuments.mx/reader035/viewer/2022062513/557210cc497959fc0b8db0d4/html5/thumbnails/15.jpg)
3. A program to print the number as a product of prime factors.
![Page 16: A Program Asking the User to Unscramble the Scrambled Word](https://reader035.vdocuments.mx/reader035/viewer/2022062513/557210cc497959fc0b8db0d4/html5/thumbnails/16.jpg)
CODING:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int n,r=0,p,a;
n=Integer.parseInt(t1.getText());
a=n;
ta1.append(n + "=");
for(int i=2; i<=n; i++)
{p=0;
for(int j=1; j<=i; j++)
{if(i%j==0)
{p++;
r=i;
}
}
if(p==2)
{while(a%r==0)
{a=a/r;
ta1.append(r + "x");
}
}
}ta1.append("1" + "\n");
}
![Page 17: A Program Asking the User to Unscramble the Scrambled Word](https://reader035.vdocuments.mx/reader035/viewer/2022062513/557210cc497959fc0b8db0d4/html5/thumbnails/17.jpg)
RUN-TIME VIEW:
![Page 18: A Program Asking the User to Unscramble the Scrambled Word](https://reader035.vdocuments.mx/reader035/viewer/2022062513/557210cc497959fc0b8db0d4/html5/thumbnails/18.jpg)
4. A program to find the abundant numbers between the given two numbers.
FRAME:
![Page 19: A Program Asking the User to Unscramble the Scrambled Word](https://reader035.vdocuments.mx/reader035/viewer/2022062513/557210cc497959fc0b8db0d4/html5/thumbnails/19.jpg)
CODING
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int s;
for(int i=Integer.parseInt(t1.getText()); i<=Integer.parseInt(t2.getText()); i++)
{s=0;
for(int j=2; j<=i; j++)
{if(i%j==0)
{s=s+j;
}
}
if(s>i+i)
{ta1.append(i + "\n");
}
}
}
![Page 20: A Program Asking the User to Unscramble the Scrambled Word](https://reader035.vdocuments.mx/reader035/viewer/2022062513/557210cc497959fc0b8db0d4/html5/thumbnails/20.jpg)
RUN-TIME VIEW:
![Page 21: A Program Asking the User to Unscramble the Scrambled Word](https://reader035.vdocuments.mx/reader035/viewer/2022062513/557210cc497959fc0b8db0d4/html5/thumbnails/21.jpg)
![Page 22: A Program Asking the User to Unscramble the Scrambled Word](https://reader035.vdocuments.mx/reader035/viewer/2022062513/557210cc497959fc0b8db0d4/html5/thumbnails/22.jpg)
5. A program to check whether the number is a Kaprekar Number.
FRAME:
![Page 23: A Program Asking the User to Unscramble the Scrambled Word](https://reader035.vdocuments.mx/reader035/viewer/2022062513/557210cc497959fc0b8db0d4/html5/thumbnails/23.jpg)
CODING:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int n,a,m=0;
n=Integer.parseInt(t1.getText());
a=n*n;
while(a!=0)
{m=m+(a%10);
a/=10;
}
if(m==a)
{JOptionPane.showMessageDialog(null, "This is a Kaprekar Number.");
}
else
{ JOptionPane.showMessageDialog(null, "No. This is not a Kaprekar Number.");}
}
![Page 24: A Program Asking the User to Unscramble the Scrambled Word](https://reader035.vdocuments.mx/reader035/viewer/2022062513/557210cc497959fc0b8db0d4/html5/thumbnails/24.jpg)
RUN_TIME VIEW: