Hatena::Groupgeneration1986

有言実行。@86

 | 

2008-04-15

Assignment for CITA140 (tutoring) 02:00

Javaの宿題。

Assignment

A password testing program. Use JOptionPane for both input and display.

The user must enter a password that meets these requirements:

  • at least 8 characters in length, no spaces allowed
  • contains at least one uppercase and one lowercase letter
  • contains at least one number (digit)

If the password is bad, display an appropriate message. Give the user up to three chances.

If the password is good, enter the password a second time and check for a match.

If OK, display a "password accepted" message.


Hint: Build this program in steps.



JOptionPaneをまだ習ってないので、何なのか生徒は知らない筈。

なのに宿題にしちゃうところがこの先生の凄いところ。

3回チャレンジしてダメだった場合はどうしたらイイかまで書いといてくれ。



ぶっちゃけ完成してないけどメモ程度に。


import javax.swing.*;

public class Check2
{
	public static void main(String[] args)
	{
		String pass1;
		pass1 = JOptionPane.showInputDialog(null, 
                          "Enter your password.\n" + 
                          " Your Password must be at least 8 characters\n" +
                          " and must not have any spaces.\n" +
                          " Also the pasword must contain both uppercase and lowercase letters,\n" +
                          " and any numbers.");


		int a = 0;
		char c;
		int i = 0;

		while(i < 2)
		{
			if(pass1.length() < 8)
			{
				pass1 = JOptionPane.showInputDialog(null, 
                                           "Password must be at least 8 characters");
				i++;
			}

			while(a <= pass1.length() && i < 2)
			{				
				c = pass1.charAt(a);
				i++;
				if(!(Character.isUpperCase(c) && Character.isLowerCase(c)))
				{
					pass1 = JOptionPane.showInputDialog(null, 
                                                  "Password must contain both uppercase and lowercase letters");
				}
				a++;
			}		
			
			a = 0;
						
			while(a <= pass1.length() && i < 2)
			{
				if(pass1.charAt(a) == ' ')
				{
					pass1 = JOptionPane.showInputDialog(null, 
                                                    "Password must not have any spaces");
					i++;
				}
				a++;
			}
			
			a = 0;
			
/*
			while(a <= pass1.length() && i < 2)
			{
				c = pass1.charAt(a);
				i++;
				if(Character.isDigit(c))
				{
					pass1 = JOptionPane.showInputDialog(null, 
                                                   "Password must contain any numbers");
				}
				a++;
			}
*/			
			
		}


		
		String pass2;
		pass2 = JOptionPane.showInputDialog(null, "Reenter your password");
		
		// Checking two passwords are same or not
		if(pass1.equals(pass2))
		{
			JOptionPane.showMessageDialog(null, "Password Accepted");
		}
		else
			JOptionPane.showMessageDialog(null, "Password Unacceptable");
	}
}


7ドルの為に自分の課題よりも優先させてやってるのがばかばかしくなってきたorz

Final project for CITA240

HTMLとかJavaScriptとかVisual BasicとかさわってるクラスのFinal Project。


1) 10 page website

  • must use style (embedded)
  • at least two javascript (1 is written by your self, 1 is cut-n-paste)
  • pages related not random
  • 2 banners or buttons
  • no fatal errors (improper casting, links that don't work, not using meta tags, messy code, not commenting)
  • 1 image map with at least 5 hot spots
  • graphics
  • at leeast 1 drop-cap in a paragraph
  • table
  • 5 internal hyperlinks and 5 external hyperlinks (externals open in new tab or brower)
  • 1 free sticky that is related to the website

2) 2 page subweb

  • 1 is resume
  • 1 is all about you
  • different styles

トピックPerfumeにした!!!

JasonbubJasonbub2017/01/25 04:20заказать листовки http://wkrolik.com.ua/products/katalog

 |