1answer.
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]
3 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]3 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
What is the difference between the Internet and the World Wide Web? Explain in your own words.
vlada-n [284]

Answer: the World Wide Web is just one common area for information exchange, facilitated by global computer networks — or the Internet. (hope this helps)

Explanation:

6 0
3 years ago
Read 2 more answers
How does information promote cooperation and Industry please explain​
IRISSAK [1]

Answer:

Provide teams with the resources they need to work together.

Train employees and encourage ongoing learning.

Encourage people to socialize outside of work.

Clarifying roles and setting expectations.

Review individual's talents.

Explanation:

6 0
3 years ago
Refer to the method f: Public int f( int k, int n ) { if( n == k ) return k; else if( n &gt; k ) return f( k, n - k ); else retu
Debora [2.8K]

Answer:

Returned value: 2

Explanation:

Public int f(int k, int n) {

   if (n == k)

       return k;

   else if (n > k)

       return f(k, n - k);

   else return f(k - n, n);

}

/////////////////////////////////////////////////////////////////////////////////////////

Trace of function calls,

f(6, 8)

f(k, n - k) -> (6, 2)

f(k - n, n) -> (4, 2)

f(k - n, n) -> (2, 2)

return k

5 0
3 years ago
Rags or wipes are considered non-hazardous waste when they are
nalin [4]
Under the Solvent-Contaminated Wipes Rule (also known as the “Wipes Rule”), solvent-contaminated wipes sent for cleaning or disposal are conditionally excluded from hazardous waste regulation. As long as the solvent-contaminated wipes meet those conditions mentioned above, they are not considered hazardous waste Under the Resource Conservation and Recovery Act (RCRA),
4 0
4 years ago
Read 2 more answers
What does it mean by MYRIAD of data?
pentagon [3]

Answer:

The term Myriad means an indefinitely large number of things. And when we say Myriad of data, we mean an indefinitely large amount of data like in Petabytes.

Explanation:

What it does implies is that you are dealing with a large amount of data. And hence we are dealing with something like bigData. And hence, technologies related to BigData are going to operate. And this term is used as a noun as well as an adjective when we talk about English. And hence, you can use it with "a" or without the "a" as well. It has been a part of reputable English and has been repeatedly used by top authors like Milton.

5 0
4 years ago
Other questions:
  • What is the height of the tallest possible red-black tree containing 31 values?
    7·1 answer
  • Which characteristic would be best for a person seeking a career in the Telecommunications pathway?
    15·1 answer
  • The box formed by the intersection of a row and column in a spreadsheet program is known as a ________.
    13·1 answer
  • You have answered 4 of 18 questions.
    12·2 answers
  • In an information systems framework, ________ is the bridge between the computer side on the left and the human side on the righ
    14·1 answer
  • Let’s say you’re having trouble locating a file on your computer. Which of the following are good places to look for the file?
    14·1 answer
  • To date, what has most propelled the digital revolution?
    10·1 answer
  • What would a bar graph best be used for? State why and give 2-3 examples of things you could demonstrate with a bar graph
    5·1 answer
  • What is added to brining liquid to add flavour​
    6·1 answer
  • windows switches to secure desktop mode when the uac prompt appears. what is the objective of secure desktop mode?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!