answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Dafna1 [17]
2 years ago
11

In this assessment, you will design and code a Java console application that validates the data entry of a course code (like IT4

782) and report back if the course code is valid or not valid. The application uses the Java char and String data types to implement the validation. You can use either the Toolwire environment or your local Java development environment to complete this assignment. The requirements of this application are as follows: The application is to read a course code entered by the user from the keyboard. The course code is made of 5 characters and should follow these rules: • First character is always an upper case I or a lower case i • Second character is always an upper case T or a lower case t • Third, fourth, fifth, and sixth characters are always digits (0-9) The application then validates the course code against above the rules and prints a message if the course code is valid or not. If the course code is not valid, the application should print a message explaining why the course code is not valid. Use these course codes to test your application: IT4782 iT4782 OT4782 it&782 Successful completion of this assignment will show a valid message or an invalid message for the entered course code. In addition, if the course code is invalid, the application should identify the reason for the invalidation. Your program output should look like this sample output:
Computers and Technology
1 answer:
ivolga24 [154]2 years ago
4 0

Answer:

The program is written using jCreator IDE

Comments are used for explanatory purpose

Program starts here

import java.util.*;

public class courecode

{

public static void main(String [] args)

{

 String ccode; // Declare course code as string

 Scanner input = new Scanner(System.in);

 System.out.print("Course code: "); // Prompt user for input

 ccode = input.nextLine();

 boolean flag = true; // Initialize a boolean variable to true

 if(ccode.length() != 6) // Check if length of course code is 6

 {

  System.out.print("Input length must be 6"); //Display message if length of input string is not 6

 }

 else // If length is 6

 {

  for(int i = 0; i<6;i++) //check validity if input string using for loop

  {

   if(i == 0) //Test for first character

   {

    //The following if statement will be executed if the first character is not i or I

    if(ccode.charAt(i) != 'i' && ccode.charAt(i) != 'I')

    {

     System.out.println("Invalid Course Code");

     System.out.println("The course code must start with an i or I");

     flag = false; //Set boolean variable to false

     break;

    }

   }

   else if(i == 1)

   {

    //The following if statement will be executed if the second character is not t or T

    if(ccode.charAt(i) != 't' && ccode.charAt(i) != 'T')

    {

     System.out.println("Invalid Course Code");

     System.out.print("The second letter of the course code must be t or T");

     flag = false; //Set boolean variable to false

     break;

    }

   }

   else

   {

    //The following if statement will be executed if any of the last 4 characters is not an integer

    if(!Character.isDigit(ccode.charAt(i)))

    {

     System.out.println("Invalid Course Code");

     System.out.print("The last 4 characters of the course code must be an integer");

     flag = false; //Set boolean variable to false

     break;

    }

   }

  }  

 }

 //The following statment checks if boolean variable flag is still true

 // If true, then the input course code is valid and the accompanying print statement will be executed

 if(flag)

 {

  System.out.print("The input course code is valid");

 }  

}  

}

Explanation:

Lines marked with // are comments

Check comments (//) for explanation

You might be interested in
How can you check an orthographic drawing to be sure there are no missing lines
user100 [1]
With an magnify glass
4 0
2 years ago
Earlier in the day, you created a user account for Brenda Cassini (bcassini). When she tries to log in, she can't. You realize t
kolezko [41]

Answer:

idk

Explanation:

how bout idk maybe ask ur teacher dont be afraid to ask thats what they're there for

just saying not tryna be rude or anything

7 0
2 years ago
Read 2 more answers
An administrator is investigating a failure on a trunk link between a Cisco switch and a switch from another vendor. After a few
vodka [1.7K]

Answer:

Option C is the correct option.

Explanation:

While the investigation about the trunk failure connection between the Cisco switch and that switch has a different vendor. The investigator noticed later some procedures that the following switch are not transacting a trunk. So, the investigator successfully finds the feasible cause of that issue which is DTP does not accept switches from different vendors.

3 0
2 years ago
Explain why the cost of ownership may be lower with a cloud database than with a traditional, company database.
geniusboy [140]

Answer:

Cloud database eliminates the need for establishing and maintaining data centres.

Explanation:

Cloud computing provides an organisation with the infrastructure they need but can not afford. A large online storage with access control policies is available based to subscription.

For a company to establish a data centre, they would need a team of skilled network engineers, fleet of high speed server systems and large storage devices.

The daily power supply and management, coupled with the needed skills and items, can be overwhelming for a company whose main objective is not to deliver database services. So cloud computing is adopted to reduce the cost.

4 0
2 years ago
Communication mode which supports data in both directions at the same time is called
xeze [42]

Answer:

duplex mode

Explanation:

It is the duplex mode. In this mode, communication is in both directions at the same time. And it is different from the simplex or the semi duplex types in which the communication is one way only or one way at a time only. Thus, duplex mode seems to be requiring more bandwidth certainly but it can be advantageous definitely, and in situations like real tine communication, when we don't have the time and want to send as well receive the message at the same time.

7 0
2 years ago
Other questions:
  • Which are methods used to improve reading fluency? Check all that apply. Practicing with a weak reader listening to a fluent rea
    5·2 answers
  • Isabel is creating a wireframe. She has drawn a layout for the home page along with outlining the navigation elements. She now w
    15·2 answers
  • You and your friend who lives far away want to fairly and randomly select which of the two of you will travel to the other’s hom
    6·1 answer
  • Replace any alphabetic character with '_' in 2-character string passCode. Ex: If passCode is "9a", output is: 9_
    6·1 answer
  • ________ is a free online service that enables a user to contact a cell phone number to hear who answers the telephone without i
    5·1 answer
  • When using the following symbol, there are two arrows coming out of it. One arrow corresponds to what happens in the program if
    7·1 answer
  • Assume you have a variable, budget, that is associated with a positive integer. Assume you have another variable, shopping_list,
    11·1 answer
  • Which option in the Caption dialog box configures whether the caption appears above or below the image
    11·2 answers
  • What does NOT match with Agile Manifesto?
    9·1 answer
  • Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!