i wrote a program to help input User ID's for a system admin can any one check the code to seewhat wrong with it
thank you
i wrote a program to help input User ID's for a system admin can any one check the code to seewhat wrong with it
thank you
import javax.swing.*;
public class TestUserAccount// Driver Class
{
public static void main(String[] args)
{
String employeeFirst ="";
String employeeLast ="";
String social ="";
UserAccount[] userObjects = new UserAccount[10];
int vount = 0;
char countiues = 'Y';
while (countiues == 'Y')
{
//Ask the user for the Employee's first Name
employeeFirst = JOptionPane.showInputDialog("Please enter the Fast Name of Employee");
//Ask the user for the Employee's last name
employeeLast = JOptionPane.showInputDialog("Please enter the Last Name of the Employee");
// Ask the user for the Employee's Social Security #
social=JOptionPane.showInputDialog("Please ent the Social Security # in 999-99-9999 format");
UserAccount myUserAccount = new UserAccount (employeeFirsrt,employeeLast,social);
if (count == userObjects.length)
{
UserAccount[] temp = new UserAccount [ userObjects.length*2];
for ( int i = 0; i < userObjects.length; i++)
{
temp[i] = userObjects[i];
userObjects = temp;
}
countiues = JOptionPane.showInputDialog("Would you like to contiueY/N").charAt(0);
}
JOptionPane.showMessageDialog(null,userObjects);
// to ensure when using JOptionPane that you terminate the program
System.exit(0);
}
}
}
/* Steven M Johnston
* CMP 218
*Professor Ganson
*Project 2 - System Admin. User ID;s
*/
import java . util.*;
public class UserAccount
{
// Instance Variables
private String firstName;
private String lastName;
private String social;
}
// Parameterized Constructor
public UserAccount (String firstName , String lastName , String social)
{
this.firstName = firstName;
this.lastName = lastName;
this.social= social;
}
// Default Constructoer
public userAccount()
{
this ("aaa","bbb", "999-99-9999");
}
// Instance Method to get lastname , firstname
public String getFullName()
{
return lastName + "," + firstName ;
}
// Instance Method to get first 3 letter of the lastName and the last 4 of the social
public String getUserNameV1()
{
String userNameV1 = "";
userNameV1 = (lastName.substring (0,3)).toLowerCase()+ social.substring(7);
return userNameV1;
}
//Instance Method to get Backwards version of UserNameV1
public String getUserNameV1Mirror()
{
Stringbuffer stbuf1 = new StringBuffer(getUserNameV1());
stbuf1.reverse();
return stbuf1.toString();
}
// Instance Method to get first initial of firstName + first initial of lastName
// last four digits of social
public String getUserNameV2 ()
{String userName2= (firstName . substring(0,1)).toLowerCase()+
(lastName.substring(0,1)).toLowerCase()+social.substring(7);
return userName2;
}
// instance Method to get alternating char. of the name (first and last ) and the social
public String getUserNameWeirdVersion()
{
int count =0;
int count2 = 0;
int num = firstName.length() + lastname.length();
int num2 = StrippedSSnum().length();
String flname = new String(firstName + lastName);
String sStrip = new StringBuffer (num+num2-2);
for(count = 0;count < num+num2 - 1; count++)
{
word,append(flName.charAt(count));
for (count2=0; count<num2-1;count++)
{
word.append(sStrip.charAt(count));
}
count++;
count2++;
}
return word.toString();
}
// Instance method to get social stripped of all dashes in String form
public String strippedSSNum()
{
String stripped = "";
int count =1;
StringTokenizer stTok1 = new StringTokenizer (social,"-");
count = sttok.countTokens();
while(stTok1.hasMoreToken())
{
stripped = stripped + (sttok.nextToken());
}
return stripped;
}
public String toString()
{
return "Employee's Full Name: "+ getFullName() +"\n"
"Employee User Name Version 1: "+getUserNameV1Mirror()
"Employee User Name Mirror Version 1: " + getUserNameV1Mirror()"\n" +
" Employee User Name Version 2:"+ getUserNameV2() +"n"+getUserNameWeirdVersion()*"\n" +
"Employee SS# (stripped: "+ strippedSSNum();
}
the UserAccount.java file was just flat out riddled with errors, I tried to correct some but ulitmately you need to learn to take more time with the java syntax
here are some corrections that should hopefully get you on your way:
Follows these steps in order on file UserAccount.java
1.) Remove the curly brace "}" on line 13 and move it to line 103
2.) change line 15 from "userAccount()" to "UserAccount()"
3.) change line 68 from "word,append" to "word.append"
4.) add a "+" to the end of line 97 and 98
5.) change getUserNameV1Mirror()"\n" to getUserNameV1Mirror()+"\n"
6.) remove the asterick (*) from line 100 and change it to a +
7.) change line 44 "Stringbuffer" to "StringBuffer"
8.) change line 61 from "lastname" to "lastName"
I am not going to go any further on this as there were still plenty of errors
thanks for the help it helped out a little but still alot of errors trying to work them out
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.