Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am developing this code in Java for as part of my project for a Student Information System (SIS). I would like to include an

I am developing this code in Java for as part of my project for a Student Information System (SIS). I would like to include an Admin log in, with username and password to allow allow admin staff to enter their log in details and access the SIS. Could you please help me.?

import java.util.*;

public class Student { private String id; private String name; private int age; private String email; private String course; private String year; private String section; /** Constructs a Student object with the given values */ public Student(String id, String name, int age, String email, String course, String year, String section){ this.id = id; this.name = name; this.age = age; this.email = email; this.course = course; this.year = year; this.section = section; } /** Returns the ID of this Student */ public String getid(){ return id; } /** Returns the name of this Student */ public String getName(){ return name; } /** Returns the age of this Student */ public int getAge(){ return age; } /** Returns the email of this student */ public String getEmail(){ return email; } /** Returns the course of this Student */ public String getCourse(){ return course; } /** Returns the year of this Student */ public String getYear(){ return year; } /** Returns the section of this Student */ public String getSection(){ return section; }

public static void main(String[] args) { int x = 0; int menuChoice = -1; Student[] students = new Student[30]; //As a note, hard-coding this '30' is a bad idea. //Probably should be static, final const in class. Scanner input = new Scanner (System.in); do{ System.out.println("\t\t\tStudent Record Menu"); System.out.println(" Please choose one of the folllowing options:"); System.out.println(" 1. Add Student 2. View Students 3. Search Student 4. Exit"); System.out.println("Enter a choice: "); menuChoice = input.nextInt(); if (menuChoice==1){ if(x < 30) { //Able to add new student. System.out.println("Student ID:"); String id = input.next(); System.out.println("Full name:"); String name = input.next(); //This was your error - should be next like the others, //Not nextLine() System.out.println("Age:"); int age = input.nextInt(); System.out.println("email"); String email = input.next(); System.out.println("Course:"); String course = input.next(); System.out.println("Year:"); String year = input.next(); System.out.println("Section:"); String section = input.next(); //Create the new student using the given inputs Student s = new Student(id, name, age, email, course, year, section); //Place in array students[x] = s; //Increment x for next student placement x++; } else { //Not able to add new student System.out.println("Can't add new student, students full"); } } else if (menuChoice==2) { for (int i=0; i 4){ System.out.println("Unrecognized menu choice; please re-enter"); } } while (menuChoice != 4); //Do close your scanners when you're done with them to avoid a resource leak. //This is closing System.in (which is bad), but you're code is terminating anyway //so its ok input.close(); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What is the meaning and definition of E-Business?

Answered: 1 week ago