By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,798 Members | 1,336 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,798 IT Pros & Developers. It's quick & easy.

Help urgently please.

P: 7
I need help with these two question..has any one got idea for these two question..

Question 1:
I need to write an application that accepts a userís password from the keyboard. When the entered password is less than six characters, more than ten characters, or doesnít contain at least one letter and one digit, prompt the user again. When the userís entry meets all the password requirements, prompt the user to re-enter the password, and do not let the user continue until the second password matches the first one.


Question 2:
I have been asked to write a Java application that will calculate an estimated tax for a tax payer, based on keyboard responses. This application will be used by taxpayers to calculate their personal tax liability.

The TaxReturn class contains field for taxpayerís Social Security Number, surname, first name street address, city, post code, annual income, marital status, and tax liability. Include a constructor that requires arguments that provide value for all of the fields other than the tax liability based on annual income and marital status:

Single Married
Income
0 - 15000 5% 5%
15001- 25000 15% 10%
25001 Ė 40000 25% 20%
40001 Over 35% 30%

Create an application that prompts a user for the data needed to create a tax return display that contains details of the taxpayer in a readable presentable format along with their tax liability and the date.

Your application should make the following validations
 The SSN should be in the right format, i.e 9 characters, the first two and the last one are letters, the rest are numbers.
 The Post code should not be more than 7 characters, the first two are letters the third is a number and the rest doesnít matter (for the sake of this exercise)
 Maritial status cannot accept any other character than m,M,s,S
 And of course the annual income cannot be negative.
Dec 6 '06 #1
Share this Question
Share on Google+
1 Reply


DeMan
100+
P: 1,806
It would help if you posted code excerpts to show progress.....

1) I am going to assume there is no requisite to mask at this stage, I am also goind to assume that you understand the basic Java language, so the problem is not so much with the input and length checking it is with the verifying a character and an int are there.....

Create an ArrayList (charArrayList) with all (upppercase & lowercase) characters.
Create another ArrayList i(intArrayList) with all the integers in it.

Create a Set (mySet)and add (individually) all the characters from your string into it (but keep the string (passString) too).

then:
Expand|Select|Wrap|Line Numbers
  1. tempSet=mySet.clone() //make a copy of this set
  2. tempSet.retainAll(charArrayList) //get rid of everything that is not an alphabetic char
  3. mySet.retainAll(intArrayList) //get rid of everything that is not an int
  4.  
  5. if(mySet.size()>0 && tempSet.size()>0)
  6. {
  7.   //myString is good (assuming you ested lengths before)
  8. }
  9. else
  10. {
  11.   //myString is not so good
  12. }
  13.  
Then, seeing as you atored the String earlier, loop until the user enters it again



2) I leave it to you to implement the TaxReturn class (there are many resources around to help you)

You can implement a class containing methods isAlpa and isNum (which might help you make the ealier code much simpler) and use this to test the elements of the SSN String

This will also help you verify the Post Code

Marital status should be trivial to implement

income check should be trivial.





If you are still having trouble, post code to show progress.....
Dec 6 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.