Loading
notes intro/old submit AP Problems the dump links
  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 included method readString (that reads from the users input) 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.

ec2: create an efficient method to determine if a number is prime

ec2b: print out all the primes you can, starting at 2 (of course using your method above)

import java.util.Scanner;

public class ForWhileAssignments {

	public void funDraw()
	{

	}

	public void findFactors(int x)
	{

	}

	public String findPassword()
	{
        //an example of asking the user for a password and reading it in using the included method
        System.out.println("Enter a password");
        String password=readString();
		return "";
	}

	public void pyramid(int rows)
	{

	}
	/**
	 * This method will read in what the user has typed as a string
	 * @return The inputted string
	 */
	public String readString()
	{
		Scanner scan=new Scanner(System.in);
		String theInputtedString=scan.nextLine();
		return theInputtedString;
	}

	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);

	}

}