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)
Need Java help: 1. Create a Java program that accepts input String input from a user of first name. 2. Create a Java program that accepts input String input from a user of last name. 3. Concatenate the Strings in a full name variable and print to the console.
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...
PLEASE INCLUDE COMMENTS In java Create a Java Program Add the following comments at the beginning of the file: Your name. The name of the class(es) used in the program. The core concept (found below) for this lesson. The date the program was written. Include a recursive method separate from the main method that will add together all of the even numbers between and including 1 and the value the user supplies. For instance, if the user enters 10 then...
Create a Python Program that will ask the user for a password (use input) Verify that the password meets the following conditions: -must be 12 characters long -must have uppercase and lowercase -must contain at least 1 special character (!~#$%^&*{}+_) -must be a mix of numbers and letters You must do this only using regular expressions so for instance this will not be accepted if len(password) <12: At the end of the program tell the user their password is ok...
Create a Python Program that will ask the user for a password (use input) Verify that the password meets the following conditions: -must be 12 characters long -must have uppercase and lowercase -must contain at least 1 special character (!~#$%^&*{}+_) -must be a mix of numbers and letters You must do this only using regular expressions so for instance this will not be accepted if len(password) <12: At the end of the program tell the user their password is ok...
Write the following program in Java. Create an abstract Vehicle class - Vehicle should have a float Speed and string Name, an abstract method Drive, and include a constructor. Create a Tesla class - Tesla inherits from Vehicle. - Tesla has an int Capacity. - Include a constructor with the variables, and use super to set the parent class members. - Override Drive to increase the speed by 1 each time. - Add a toString to print the name, speed,...
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...