| for
and while assignments
Create a class called: ForWhileAssignments (starter code below)
1. Create a method funDraw() that will draw this 10000 times:
*
**
***
****
*****
****
***
**
*
**
***
****
2. Create a method findFactors(int x) that will print out all the
factors of a number:
ie findFactors(24) would print out
1,2,3,4,6,8,12,24
3. Create a method called String findPassword() that will use the Scanner class and keep asking the user for a password until it has
between 6 and 8 letters and it will return that password.
4. Create a method called public void pyramid(int rows) that will print a pyramid
like below with the number of rows specified
1
12
123
1234
12345
123456
...
ec: create a method called String findSecurePassword() that will
use the Scanner class and keep asking the user for a password until
it has between 6 and 8 characters, with atleast 1 number in it and at least 1 letter; it will
return that password. For real extra credit make it use capital and lower case letters and any extra checks you can think of. For full credit, use your method findPassword()
above.
public class ForWhileAssignments {
public void funDraw()
{
}
public void findFactors(int x)
{
}
public String findPassword()
{
return "";
}
public void pyramid(int rows)
{
}
public static void main(String[] args) {
// TODO Auto-generated method stub
ForWhileAssignments f=new ForWhileAssignments();
f.funDraw();
f.findFactors(24);
System.out.println("Your password is "+f.findPassword());
f.pyramid(5);
}
}
|