In Java Write a program that checks the properness of a given variable name. More specifically, your program should specify whether a user-entered variable name is (1) illegal, (2) legal but uses poor style, or (3) good. There are different opinions as to what constitutes a good style for a variable name. For this program, check for good style using these rules: · Only use letters and digits. · Use a lowercase letter for the first character. You do not need to check for an uppercase letter for the first letter in the second and third words, ...etc. Your program should repeatedly prompt the user for variable names until the user enters "q" or "Q." the program terminates when the user enters the "q" or "Q."  Sample session: This program checks the properness of a proposed Java variable name. Enter a variable name (q or Q to quit): streetAddress2 Good! Enter a variable name (q or Q to quit): street address2 Illegal. Enter a variable name (q or Q to quit): StreetAddress2 Legal, but uses poor style. Enter a variable name (q or Q to quit): 2ndStreetAddress Illegal. Enter a variable name (q or Q to quit): street$address$2 Legal, but uses poor style. Enter a variable name (q or Q to quit): q   public class VariableNameChecker { public static void main (String [] args)  {  String varName;  Scanner stdIn = new Scanner (System.in);  //prompt the user to enter a variable name  boolean valid = VariableChecker(varName); // to check if it it legal  if (valid)  {  // your code to check for good style  }  else{  // illegal  }  //repeatedly prompt the user for variable names until the user enters "q" or "Q.  }// end main public static boolean VariableChecker(String varName)  {  // your code  } // return your variable.  } // end class

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

In Java

Write a program that checks the properness of a given variable name. More
specifically, your program should specify whether a user-entered variable name
is (1) illegal, (2) legal but uses poor style, or (3) good. There are different
opinions as to what constitutes a good style for a variable name. For this
program, check for good style using these rules:
· Only use letters and digits.
· Use a lowercase letter for the first character.
You do not need to check for an uppercase letter for the first letter in the second
and third words, ...etc.
Your program should repeatedly prompt the user for variable names until the user
enters "q" or "Q." the program terminates when the user enters the "q" or "Q." 

Sample session:
This program checks the properness of a proposed Java variable name.
Enter a variable name (q or Q to quit): streetAddress2
Good!
Enter a variable name (q or Q to quit): street address2
Illegal.
Enter a variable name (q or Q to quit): StreetAddress2
Legal, but uses poor style.
Enter a variable name (q or Q to quit): 2ndStreetAddress
Illegal.
Enter a variable name (q or Q to quit): street$address$2
Legal, but uses poor style.
Enter a variable name (q or Q to quit): q

 

public class VariableNameChecker
{
public static void main (String [] args)
 {
 String varName;
 Scanner stdIn = new Scanner (System.in);
 //prompt the user to enter a variable name
 boolean valid = VariableChecker(varName); // to check if
it it legal
 if (valid)
 {
 // your code to check for good style
 }

 else{
 // illegal
 }
 //repeatedly prompt the user for variable names until the
user enters "q" or "Q.
 }// end main
public static boolean VariableChecker(String varName)
 {
 // your code


 } // return your variable.
 } // end class 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Top down approach design
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education