Answer to Question #267712 in Java | JSP | JSF for candy

Question #267712

4.The system verify the username and password. If wrong username,

please show the error message: Wrong username, please check and the re-enter your username. If wrong password,

please show the error message: Wrong password, please check and re-enter your password.

 

Display message to ask the user input

User name and password validation

Display the error message.

use of loop so user could re-enter the username/password when wrong input

 

If successful login, display the summary of the student

 

Correct format

Full set of details included as shown in the example

display of modules details

calculation of average mark, average attendance, grade conversion and correct display of remark message


1
Expert's answer
2021-11-18T15:17:00-0500


SOLUTION TO THE ABOVE QUESTION


SOLUTION CODE


package com.company;
import java.util.ArrayList;
import java.util.*;
class Main{
    public static void main(String arg[])
    {
        Scanner sc = new Scanner(System.in);
        //Take note in this program we will use "Kelly"as user name and dan as password
        //propmt the user to enter the username;
        String username;
        int condition_1 = 1;
        do {
            System.out.print("Enter your username: ");
            username = sc.next();
            if(username.equals("Kelly"))
            {
                condition_1 = 0;
            }
            else{
                System.out.println("Wrong username, please check and then re-enter your username");
            }

        }while (condition_1==1);

        String password;
        int condition_2 = 1;
        do {
            System.out.print("Enter your Password: ");
            password = sc.next();
            if(password.equals("dan"))
            {
                condition_2 = 0;
            }
            else
            {
                System.out.println("Wrong password, please check and re-enter your password.");
            }

        }while (condition_2 == 1);

        //Now print the message that login is successful
        System.out.println("\nLogin successful.");
        //now lets dispaly the information of the user

        System.out.println("\nDear Kelly, Your average mark is 70");
        System.out.println("\nThe grade is A");
        System.out.println("\nFirst Class honours");



    }
}


SAMPLE PROGRAM OUTPUT






Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS