Using java program, create a Username class.
ask user to type username
1)username length have to >1 and <15
2)username can not include any special character (ex.!@##$}{|\....) ,but it also have to type Spanish or other foreign language
3)user can not include any empty space (ex. user name)
all of three error have to print out. and if there is any error contains, have to ask user to input user name again.
for example:
input username: #$%he f
username can't include any special character
username can't have any empty space
input username: (ask user to input again if there is errors)
Dear student the here is the java code and the output is below the code name the java file as Username.java
Username.java
import java.util.Scanner;
public class Username {
public static void main(String[] args) {
// TODO Auto-generated method
stub
Scanner sc=new
Scanner(System.in);
boolean flag=false;
String uname="";
do {
System.out.println("Enter the
username");
uname=sc.nextLine();
for(int
i=0;i<uname.length();i++)
{
if(uname.length()<=1 || uname.length()>=15)
{
flag=true;
System.out.println("The length should be > 1
and <15");
break;
}
else
if(Character.isSpace(uname.charAt(i)))
{
flag=true;
System.out.println("the username doesnot contain
spaces");
break;
}
else
if(!(Character.isLetter(uname.charAt(i)) ||
Character.isDigit(uname.charAt(i))))
{
flag=true;
System.out.println("the username doesnot contain
specail characters");
break;
}
else {
flag=false;
}
}
}while(flag);
System.out.println("The username is "+uname);
}
}
output:
Enter the username
Bhargavramasitarama
The length should be > 1 and <15
Enter the username
Bhargav@
the username doesnot contain specail characters
Enter the username
Bhargav rama
the username doesnot contain spaces
Enter the username
Bhargav
The username is Bhargav
Using java program, create a Username class. ask user to type username 1)username length have to...
use java program, create a class with conditions below. 1. asking user to type int number 2.you have to receive it use next String (not next int) 3.use try catch , if user input is not int, ask them to retype int number. (have to print out message that said only type int number)
(Java) HELP! Create a program that will ask the user to enter their first name and their favorite number. Ask the user if they would like the information repeated back to them. If they type "Y" display the answers back to them. If they type anything else, display the word "Goodbye". An example of what your output window should look like is below. The system-generated output is in red. The user-provided input is in green. (Your actual program will only...
1. use the main method 2. ask the user to enter a name at the terminal 3. ask the user to continue to add name (use Y/N) 4. as long as the user type Y. keep asking them to enter a name. 5. at N (no) print out the following: LAST NAME, firstname Language: java for all lthe entries. ex. Enter a Name Tom Harper Enter a new name ? (Y/N) Y Enter a Name Sue Bird Enter a new...
Introduction to Java programming You will create a secure password. Ask a user to enter first name and last name. (Allow for mixed case) Create a random integer from 10-99. Create the password string that consists of the upper case letter of the last letter of his/her first name, the random number, and the first three letters of his/her last name in lower case. Example someone with the name Rob Lee might have a password that looks like B56lee. Your...
This is a Java text only program. This program will ask if the user wants to create a music playlist. If user says he or she would like to create this playlist, then the program should first ask for a name for the playlist and how many songs will be in the playlist. The user should be informed that playlist should have a minimum of 3 songs and a maximum of 10 songs. Next, the program will begin a loop...
Part I Create a Java program that inputs a grade from the user. The grade input from the user will be an integer. Once the input is stored, use an if-else-if block of code to determine the letter grade of the inputted integer grade. Do not use a bunch of if statements by themselves to solve this problem. You will print an error message for inputs greater than 100 and for inputs less than 0. Both errors must be handled...
Create a program in Java with the following requirements: Using a Scanner and print statements, ask the user to input 3 numbers. Use Java’s int data type…don’t worry about error checking for this assignment (assume the user doesn’t try to break your program) Store these three numbers into three variables Calculate the sum of all three numbers Calculate the product of all three numbers If all three numbers are even, output “Lucky Duck!” If all three numbers are odd, output...
Write a program that will check a Java file for syntax errors. The program will ask for an input-file name and output-file name and will then copy all the code from the Java input file to the Java output file, but with the following changes: 1. Any syntax error found in the Java input file will be corrected: a. Missing semicolon b. Missing compound statements (curly braces) c. All comments have to start with // and end with a period....
Java programming only Create a Java program that inputs a grade from the user. The grade input from the user will be an integer. Once the input is stored, use an if-else-if block of code to determine the letter grade of the inputted integer grade. Do not use a bunch of if statements by themselves to solve this problem. You will print an error message for inputs greater than 100 and for inputs less than 0. Both errors must be...
You are to write a Java Class using Generics. This class is to be a Double Linked List container for holding other objects which are comparable. The Class should support the following features: Print the elements of the collection in order (ascending). Insert an item. Remove an item. Empty the collection. Find the index of an element, using a binary recursive search. The program should include a driver class (Main) that provides a command line input/output. This driver class should:...