On a 10-day basic course write down the code, bo you a smile

Source: Internet
Author: User

Import Java.util.Scanner;

public class GradeManage1 {
Information: User name, password, student name, school number, score. Each array (the array of each information is labeled the same)
/**
* users--user name passwords--password names--name numbers--study number grades--score problems--feedback question
* (currently known bug: Feedback name and score one question, will replace the first feedback) has not yet realized the function: feedback problem after processing out of feedback
* (Late expansion function: The number of registered accounts up to the limit, feedback to the administrator, the administrator can increase the number of arrays)
*/
public static void Main (string[] args) {
SYSTEM.OUT.PRINTLN ("* * Welcome to Student Information Management system * *");
string[] users = new STRING[3];
string[] passwords = new STRING[3];
string[] names = new String[3];
int[] numbers = new INT[3];
Int[] Grades = new INT[3];
string[] problems = new STRING[3];
Users[0] = "admin";
Passwords[0] = "123456";
Names[0] = "Administrator";
Menu (Users, passwords, names, numbers, grades, problems);
}

/**
* Login Homepage
*/
public static void menu (string[] users, string[] passwords, string[] names, int[] numbers, int[] grades,
String[] problems) {
Scanner S1 = new Scanner (system.in);
System.out.println ("main Menu" Please select function: ");
System.out.println ("1. Registration");
System.out.println ("2. Login:");
System.out.println ("3. Administrator Portal:");
System.out.println ("4. Exit");
String input = S1.nextline ();
switch (input) {
Case "1":
Regist (Users, passwords, names, numbers, grades, problems);
Break
Case "2":
Login (users, passwords, names, numbers, grades, problems);
Break
Case "3":
Admininput (Users, passwords, names, numbers, grades, problems);
Break
Case "4":
SYSTEM.OUT.PRINTLN ("* * * Welcome to use, goodbye!) ***");
System.exit (0);
Default
SYSTEM.OUT.PRINTLN ("Input error, please re-enter");
Menu (Users, passwords, names, numbers, grades, problems);
}
}

/**
* < students > Registration screen
*/
public static void Regist (string[] users, string[] passwords, string[] names, int[] numbers, int[] grades,
String[] problems) {
Scanner S1 = new Scanner (system.in);
System.out.println ("Please fill in the following information separately" enter OK ");
System.out.println ("1. User name:");
System.out.println ("2. Password:");
System.out.println ("3. Name:");
String user = S1.nextline ();
String password = s1.nextline ();
String name = S1.nextline ();
int k =-1;
for (int i = 0; i < users.length; i++) {
if (users[i] = = null) {
Users[i] = user;
Passwords[i] = password;
Names[i] = name;
Numbers[i] = (int) (Math.random () * 10-1);
Randomly generates a 1-9 number assigned to the number numbers array.
SYSTEM.OUT.PRINTLN ("Registration is successful, please login");
Menu (Users, passwords, names, numbers, grades, problems);
Break
} else if (users[i].equals (user)) {
System.out.println ("The user name is already in use!") ");
Regist (Users, passwords, names, numbers, grades, problems);
} else if (i = = users.length-1) {
K = i;
}
}
if (k = = users.length-1) {
Scanner s2 = new Scanner (system.in);
System.out.println ("Allow the registered population to be full, please contact the administrator to clean up or increase capacity");
System.out.println ("Are you feedback? Y/n?\n Of course you can also press any other key to cut off the power supply 0.0 ");
String choice = S2.nextline ();
Choice = Choice.touppercase ();
if (Choice.equals ("Y")) {
Problems[0] = "The system registration number is full, please increase the capacity!" ";
Menu (Users, passwords, names, numbers, grades, problems);
} else if (Choice.equals ("N")) {
Menu (Users, passwords, names, numbers, grades, problems);
} else {
System.exit (0);
}
}
}

/**
* < students > Login screen
*/
public static void Login (string[] users, string[] passwords, string[] names, int[] numbers, int[] grades,
String[] problems) {
Scanner S1 = new Scanner (system.in);
System.out.println ("User name:");
String user = S1.nextline ();
Scanner s2 = new Scanner (system.in);
System.out.println ("Password:");
String password = s2.nextline ();
int rank =-1;
for (int i = 0; i < users.length; i++) {
if (users[i].equals (user) && passwords[i].equals (password)) {
SYSTEM.OUT.PRINTLN ("Login Successful! Welcome you "+ names[i]);
rank = i;
Rank is used to indicate that the student's array subscript
function (users, passwords, names, numbers, grades, problems, rank);
Break
} else if (i = = users.length-1) {
Index data in an array and output results in the last lookup
System.out.println ("User name or password error, please try to register or re-login");
Menu (Users, passwords, names, numbers, grades, problems);
}
}
}

/**
* < students > Login function Selection section
*/
public static void function (string[] users, string[] passwords, string[] names, int[] numbers, int[] grades,
String[] problems, int rank) {
Scanner S1 = new Scanner (system.in);
System.out.println ("Function selection:");
System.out.println ("1. Query results");
System.out.println ("2. Enquiry number");
System.out.println ("3. Change Password");
System.out.println ("4. Personal Information Error feedback");
System.out.println ("5. Logout");
String choice = S1.nextline ();
Switch (choice) {
Case "1":
System.out.println ("Your score is:" + Grades[rank]);
function (users, passwords, names, numbers, grades, problems, rank);
Break
Case "2":
System.out.println ("Your school number is: j133-" + Numbers[rank]);
function (users, passwords, names, numbers, grades, problems, rank);
Break
Case "3":
Scanner s2 = new Scanner (system.in);
System.out.println ("Please enter a new password:");
String newpsd = S2.nextline ();
Passwords[rank] = NEWPSD;
SYSTEM.OUT.PRINTLN ("Change password successfully!") ");
function (users, passwords, names, numbers, grades, problems, rank);
Break
Case "4":
Takeproblems (Users, passwords, names, numbers, grades, problems, rank);
function (users, passwords, names, numbers, grades, problems, rank);
Break
Case "5":
Menu (Users, passwords, names, numbers, grades, problems);
Break
Default
SYSTEM.OUT.PRINTLN ("Input wrong, please re-enter!") ");
function (users, passwords, names, numbers, grades, problems, rank);
}
}

/**
* < students > (login) Feedback questions
*/
public static void Takeproblems (string[] users, string[] passwords, string[] names, int[] numbers, int[] grades,
String[] problems, int rank) {
Scanner S1 = new Scanner (system.in);
SYSTEM.OUT.PRINTLN ("Student Question feedback": ");
SYSTEM.OUT.PRINTLN ("Please select exception information:");
System.out.println ("1. Name is wrong");
System.out.println ("2. Incorrect results");
System.out.println ("3. Return to previous menu");
String choice = S1.nextline ();
Switch (choice) {
Case "1":
Scanner s2 = new Scanner (system.in);
System.out.println ("Please enter the correct name:");
String turename = S2.nextline ();
Problems[rank] = "User name" + users[rank "+" Student Feedback Name: "+ turename;
+ = is to prevent if the student's performance name is wrong, the data is replaced, where the + is the connector
System.out.println ("Feedback to admin, waiting for administrator to modify");
Takeproblems (Users, passwords, names, numbers, grades, problems, rank);
Break
Case "2":
Scanner s3 = new Scanner (system.in);
System.out.println ("Please enter the correct score:");
int turegrade = S3.nextint ();
Problems[rank] = "User name" + users[rank "+" Student Feedback Name: "+ Turegrade;
System.out.println ("Feedback to admin, waiting for administrator to modify");
Takeproblems (Users, passwords, names, numbers, grades, problems, rank);
Break
Case "3":
function (users, passwords, names, numbers, grades, problems, rank);
Break
Default
SYSTEM.OUT.PRINTLN ("Input wrong, please re-enter!") ");
Takeproblems (Users, passwords, names, numbers, grades, problems, rank);
}
}

/**
* < Administrator > Login Input Confirmation
*/
public static void Admininput (string[] users, string[] passwords, string[] Names , int[] numbers, int[] grades,
string[] problems) {
Scanner S1 = new Scanner (system.in);
System.out.println ("Admin account:");
String inputuser = S1.nextline ();
Scanner s2 = new Scanner (system.in);
System.out.println ("Administrator password:");
String inputpsd = S2.nextline ();
if (Inputuser.equals (users[0]) && inputpsd.equals (Passwords[0])) {
System.out.println ("Login Successful! Welcome administrator ");
Adminmenu (Users, passwords, names, numbers, grades, problems);
} else {
System.out.println ("Incorrect account or password! ");
Menu (Users, passwords, names, numbers, grades, problems);
}
}

/**
* < admin > Login Menu Interface
*/
public static void Adminmenu (string[] users, string[] passwords, string[] names, int[] numbers, int[] grades,
String[] problems) {
Scanner S1 = new Scanner (system.in);
SYSTEM.OUT.PRINTLN ("Select function": ");
System.out.println ("1. New student Information");
System.out.println ("2. View changes to student information");
System.out.println ("3. View problem feedback");
System.out.println ("4. Change Password");
System.out.println ("5. Logout");
String input = S1.nextline ();
switch (input) {
Case "1":
Newinformation (Users, passwords, names, numbers, grades, problems);
Break
Case "2":
Findfix (Users, passwords, names, numbers, grades, problems);
Break
Case "3":
Problems (Users, passwords, names, numbers, grades, problems);
Break
Case "4":
NEWPSD (Users, passwords, names, numbers, grades, problems);
Break
Case "5":
Menu (Users, passwords, names, numbers, grades, problems);
Break
}
}

/**
* < admin > New Student Information
*/
public static void Newinformation (string[] users, string[] passwords, string[] names, int[] numbers, int[] grades,
String[] problems) {
Scanner S1 = new Scanner (system.in);
System.out.println ("New Student Information": ");
System.out.println ("Please fill in the following information separately" enter OK ");
System.out.println ("1. User name:");
System.out.println ("2. Password:");
System.out.println ("3. Name:");
System.out.println ("4. Score:");
String user = S1.nextline ();
String password = s1.nextline ();
String name = S1.nextline ();
int grade = S1.nextint ();
for (int i = 0; i < users.length; i++) {
if (users[i] = = null) {
The value of the array is null to indicate that it is not registered
Users[i] = user;
Passwords[i] = password;
Names[i] = name;
Grades[i] = grade;
System.out.println ("The student information has been added!") ");
System.out.print ("Username:" + users[i] + "Password:" + passwords[i] + "\ n Name:" + names[i] + "score" + grades[i]);
Scanner s2 = new Scanner (system.in);
System.out.println ("Continue to add? y/n? ");
SYSTEM.OUT.PRINTLN ("Input other will explode!") ");
String choice = S2.nextline ();
Choice = Choice.touppercase ();
if (Choice.equals ("Y")) {
Newinformation (Users, passwords, names, numbers, grades, problems);
} else if (Choice.equals ("N")) {
Adminmenu (Users, passwords, names, numbers, grades, problems);
} else {
System.out.println ("Cheat you!" ");
Adminmenu (Users, passwords, names, numbers, grades, problems);
}
Break
} else if (i = = users.length-1) {
Index fully
SYSTEM.OUT.PRINTLN ("Student storage is full, need to expand storage capacity!") ");
}
}
}

/**
* < admin > View Modify student Information
*/
public static void Findfix (string[] users, string[] passwords, string[] names, Int[] Numbers, int[] grades,
string[] problems) {
Scanner S1 = new Scanner (system.in);
System.out.println ("View changes to student information": ");
System.out.println ("1. Enter user name lookup");
System.out.println ("2. Enter name lookup:");
System.out.println ("3. Enter the study number to find:");
System.out.println ("4. Return to the previous menu:");
String input = S1.nextline ();
Switch (input) {
Case "1":
Find_user (Users, passwords, names, numbers, grades, problems);
Break
Case "2":
Find_name (Users, passwords, names, numbers, grades, problems);
Break
Case "3":
Find_number (Users, passwords, names, numbers, grades, problems);
Break
Case "4":
Adminmenu (Users, passwords, names, numbers, grades, problems);
Break
Default:
System.out.println ("Input error, please reenter");
Findfix (Users, passwords, names, numbers, grades, problems);
}
}

/**
* < Administrator > (find information) user name find
*/
public static void Find_user (string[] users, string[] passwords, string[] n Ames, int[] numbers, int[] grades,
string[] problems) {
Scanner S1 = new Scanner (system.in);
System.out.println ("User name:");
String user = S1.nextline ();
for (int i = 0; i < users.length; i++) {
if (users[i].equals (user)) {
System.out.println ("user" + Users[i] + " Information as follows ");
System.out.println ("" If you want to modify please enter the front number, return Please enter n "");
System.out.println ("PS: User name, school number cannot be modified");
System.out.println ("study number:" + numbers[i]);
System.out.println ("1. Name:" + names[i]);
System.out.println ("2. Score:" + grades[i]);
Fix_user (Users, passwords, names, numbers, grades, problems, I);
Findfix (Users, passwords, names, numbers, grades, problems);
}
}
}

/**
* < Administrator > (user name Lookup) modify Information
*/
public static void Fix_user (string[] users, string[] passwords, string[] Na MES, int[] numbers, int[] grades,
string[] problems, int i) {
Scanner S1 = new Scanner (system.in);
String choice = S1.nextline ();
Choice = Choice.touppercase ();
Switch (choice) {
Case "1":
System.out.println ("Modify Name:");
Scanner s2 = new Scanner (system.in);
String name = S2.nextline ();
Names[i] = name;
System.out.println ("modified successfully! ");
break;
Case "2":
System.out.println ("Modify Result:");
Scanner s3 = new Scanner (system.in);
int grade = S3.nextint ();
Grades[i] = grade;
System.out.println ("modified successfully! ");
break;
Case ' N ':
break;
Default:
System.out.println ("Input error, please reenter");
Find_user (Users, passwords, names, numbers, grades, problems);
}
}

/**
* < Administrator > (find information) name Lookup
*/
public static void Find_name (string[] users, string[] passwords, string[] Na MES, int[] numbers, int[] grades,
string[] problems) {
Scanner S1 = new Scanner (system.in);
System.out.println ("Name:");
String name = S1.nextline ();
for (int i = 0; i < names.length; i++) {
if (names[i].equals (name)) {
System.out.println ("name + Names[i] +" Information as follows ");
System.out.println ("" If you want to modify please enter the front number, return Please enter n "");
System.out.println ("PS: User name, school number cannot be modified");
System.out.println ("study number:" + numbers[i]);
System.out.println ("User name:" + users[i]);
System.out.println ("1. Score:" + grades[i]);
Fix_name (Users, passwords, names, numbers, grades, problems, I);
Findfix (Users, passwords, names, numbers, grades, problems);
}
}
}

/**
* < Administrator > (name lookup) modify Information
*/
public static void Fix_name (string[] users, string[] passwords, string[] Nam ES, int[] numbers, int[] grades,
string[] problems, int i) {
Scanner S1 = new Scanner (system.in);
String choice = S1.nextline ();
Choice = Choice.touppercase ();
Switch (choice) {
Case "1":
System.out.println ("Modify Result:");
Scanner s2 = new Scanner (system.in);
int grade = S2.nextint ();
Grades[i] = grade;
System.out.println ("modified successfully! ");
break;
Case ' N ':
break;
Default:
System.out.println ("Input error, please reenter");
Find_name (Users, passwords, names, numbers, grades, problems);
}
}

/**
* < Administrator > (find information) study number lookup
*/
public static void Find_number (string[] users, string[] passwords, string[] Names, int[] numbers, int[] grades,
string[] problems) {
Scanner S1 = new Scanner (system.in);
System.out.println ("Study No.:");
int number = S1.nextint ();
for (int i = 0; i < numbers.length; i++) {
if (numbers[i] = = number) {
System.out.println ("study number" + Numbers[i] + "Information is as follows");
System.out.println ("" If you want to modify please enter the front number, return Please enter n "");
System.out.println ("PS: User name, school number cannot be modified");
System.out.println ("User name:" + users[i]);
System.out.println ("1. Name:" + names[i]);
System.out.println ("2. Score:" + grades[i]);
Fix_number (Users, passwords, names, numbers, grades, problems, I);
Findfix (Users, passwords, names, numbers, grades, problems);
}
}
}

/**
* < Administrator > (user name Lookup) modify Information
*/
public static void Fix_number (string[] users, string[] passwords, string[] Names, int[] numbers, int[] grades,
string[] problems, int i) {
Scanner S1 = new Scanner (system.in);
String choice = S1.nextline ();
Choice = Choice.touppercase ();
Switch (choice) {
Case "1":
System.out.println ("Modify Name:");
Scanner s2 = new Scanner (system.in);
String name = S2.nextline ();
Names[i] = name;
System.out.println ("modified successfully! ");
break;
Case "2":
System.out.println ("Modify Result:");
Scanner s3 = new Scanner (system.in);
int grade = S3.nextint ();
Grades[i] = grade;
System.out.println ("modified successfully! ");
break;
Case ' N ':
break;
Default:
System.out.println ("Input error, please reenter");
Find_number (Users, passwords, names, numbers, grades, problems);
}
}

/**
* < admin > View problem Feedback
*/
public static void problems (string[] users, string[] passwords, string[] Names , int[] numbers, int[] grades,
string[] problems) {
System.out.println ("Feedback on the following questions:");
for (int i = 0; i < users.length; i++) {
if (problems[i]! = null) {
System.out.println (problems[i]);
} else if (Problems[i] = = NULL && i = = users.length-1) {
System.out.println ("No feedback Information");
Adminmenu (Users, passwords, names, numbers, grades, problems);
}
}
}

/**
* < admin > Change Password
*/
public static void Newpsd (string[] users, string[] passwords, string[] names, int[] numbers, int[] grades,
String[] problems) {
SYSTEM.OUT.PRINTLN ("Please select": ");
Scanner S1 = new Scanner (system.in);
System.out.println ("1. Student password reset");
System.out.println ("2. Administrator password Modification:");
System.out.println ("3. return");
String input = S1.nextline ();
switch (input) {
Case "1":
STUDENTPSD (Users, passwords, names, numbers, grades, problems);
Break
Case "2":
ADMINPSD (Users, passwords, names, numbers, grades, problems);
Break
Case "3":
Adminmenu (Users, passwords, names, numbers, grades, problems);
Break
Default
SYSTEM.OUT.PRINTLN ("Input error, please re-enter");
NEWPSD (Users, passwords, names, numbers, grades, problems);
}
}

/**
* < admin > (change password) student password reset
*/

public static void Studentpsd (string[] users, string[] passwords, string[] names, int[] numbers, int[] grades,
String[] problems) {
System.out.println ("Enter the username that requires a password reset:");
Scanner S1 = new Scanner (system.in);
String user = S1.nextline ();
for (int i = 0; i < users.length; i++) {
if (users[i]! = null && user.equals (Users[i])) {
SYSTEM.OUT.PRINTLN ("New password:");
Scanner s2 = new Scanner (system.in);
String password = s2.nextline ();
Passwords[i] = password;
SYSTEM.OUT.PRINTLN ("Password has been reset! ");
NEWPSD (Users, passwords, names, numbers, grades, problems);
Break
}else if (i = = users.length-1) {
System.out.println ("The user name does not exist! ");
NEWPSD (Users, passwords, names, numbers, grades, problems);
}
}
}

/**
* < admin > (change Password) Administrator password modification
*/

public static void Adminpsd (string[] users, string[] passwords, string[] names, int[] numbers, int[] grades,
String[] problems) {
System.out.println ("Enter new password:");
Scanner S1 = new Scanner (system.in);
String password = s1.nextline ();
Passwords[0] = password;
SYSTEM.OUT.PRINTLN ("Password modified successfully");
NEWPSD (Users, passwords, names, numbers, grades, problems);
}
}

On a 10-day basic course write down the code, bo you a smile

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.