in this coding please add an address for the student to enter... note that this coding use linked list and a file text to store its data ...Please make sure the address will work with all the functions below..to check whether your coding is correct after you finished adding a new dummy student data and its information close the program and reopen it and choose the option 5 ... I've tried adding an address before but an error occurred when I reopen the program and enter option 5
int addStudent();
void display();
int update();
int search();
void save();
void read();
my coding is in the link below
https://docdro.id/2p3LNsA
Screenshot
----------------------------------------------
Program
#include <iostream>
#include <stdlib.h>
#include <fstream>
#include <string>
#include <windows.h>
using namespace std;
struct st
{
string id;
char name[50];
char grade;
string phone;
string dateofbirth;
char address[100];
struct st* next;
};
struct st* hptr = 0; // declare null header of linked list
int addStudent();
int delete_student();
void display();
int update();
int search();
void save();
void read();
void logo();
int main()
{
logo();
char ch;
int opt;
ifstream file("database.txt");
if (!file) {
goto shortcut;
}
else
read();
do
{
shortcut:
cout << "\nChoose option
:\n\n"
"============================================\n"
"\n\t1.Add
Student\n"
"\t2.Remove
Student\n"
"\t3.Update
Student Information\n"
"\t4.Search
Student\n"
"\t5.Display
Records\n"
"\n
======================================"
<<
endl;
cin >> opt;
cout << endl;
if (opt == 1) {
addStudent();
save();
}
else if (opt == 2) {
delete_student();
save();
}
else if (opt == 3) {
update();
save();
}
else
if (opt == 4)
{
search();
}
else if (opt ==
5) {
display();
}
else {
cout << "Invaild Option, Try
again...!\n";
cout << "\n" << endl;
system("pause");
system("CLS");
main();
}
cout << "Do you wants another
operation(y/n)? : ";
cin >> ch;
} while (ch == 'Y' || ch == 'y');
}
/* Add Student */
int addStudent()
{
st* temp = new st;
st* temp1 = new st;
cout << "Enter student ID :";
cin >> temp-> id;
cout << "Enter name:";
cin.ignore();
cin.getline(temp-> name, 50, '\n');
cout << "Enter grade:";
cin >> temp-> grade;
cout<< "Enter phone number: ";
cin >> temp-> phone;
cout << "Enter date of birth [day/month/year]:
";
cin >> temp-> dateofbirth;
cout << "Enter address: ";
cin.ignore();
cin.getline(temp->address, 100, '\n');
// Head of linked list is null
if (hptr == 0)
{
temp-> next = hptr;
hptr = temp;
return 0;
}
else
{
temp1 = hptr;
while (temp1-> next)
temp1
= temp1-> next;
temp-> next = temp1-> next;
//NULL
temp1-> next = temp;
return 0;
}
return -1;
}
/* Delete Student */
int delete_student()
{
string idno;
st* temp = new st;
st* temp1 = new st;
cout << "Do you want to delete a record ,then
enter student ID : ";
cin >> idno;
temp = hptr;
while (temp)
{
if (temp-> id == idno)
{
// searching
record is head
if (temp ==
hptr)
{
hptr = temp-> next;
free(temp);
return 0;
}
else
{
temp-> next = temp-> next;
free(temp);
return 0;
}
}
temp1 = temp;
temp = temp-> next;
}
cout << "Record is not found..!\n";
return -1;
}
/* Update the grade of the st
udent */
int update()
{
string idno;
st* temp = new st;
st* temp1 = new st;
cout << "Enter student ID :";
cin >> idno;
temp = hptr;
while (temp)
{
if (temp-> id == idno)
{
cout<<
"Enter grade to update:";
cin >>
temp-> grade;
cout <<
"Enter phone number to update:";
cin >>
temp-> phone;
cout <<
"Enter address to update: ";
cin.ignore();
cin.getline(temp->address, 100, '\n');
return 0;
}
temp1 = temp;
temp = temp-> next;
}
cout<< "Record not found..!\n";
return -1;
}
/* search the student */
int search()
{
string idno;
st* temp = new st;
st* temp1 = new st;
cout << "Enter student ID :";
cin >> idno;
temp = hptr;
cout<< "|Student ID .\n | Name\n | Grade\n |
Phone number\n | Date of birth\n | Address" << endl;
cout <<
"------------------------------------------ -\n";
while (temp)
{
if (temp-> id
== idno)
{
cout << temp-> id << "\n"
<< temp-> name << "\n" << temp-> grade
<< "\n" <<temp-> phone << "\n" <<
temp-> dateofbirth << "\n"
<<temp->address<<"\n"<<endl;
cout << "------------------------------------------------
-"<<endl;
return 0;
}
temp1 =
temp;
temp = temp->
next;
}
cout << "Record is not present..!\n";
}
/* Display the record */
void display()
{
system("cls");
cout << "|Student ID.\n | Name\n | Grade\n |
Phone number\n | Date of birth\n | Address" << endl;
cout<<
"------------------------------------------ -\n";
struct st* ptr;
ptr = hptr;
while (ptr)
{
cout << ptr-> id <<
"\n" << ptr-> name << "\n"<< ptr-> grade
<< "\n" << ptr-> phone<< "\n" <<
ptr->dateofbirth <<
"\n"<<ptr->address<<"\n"<<endl;
cout << "------------------------------------------------
-"<<endl;
ptr = ptr-> next;
}
}
void save()
{
// stores the current data of linked list in
database.txt
ofstream fout("database.txt");
struct st* ptr;
ptr = hptr;
while (ptr)
{
fout << ptr-> id <<
"\n" << ptr-> name << "\n" << ptr-> grade
<< "\n" << ptr-> phone<< "\n"<<ptr->
dateofbirth << "\n"<<ptr->address<<"\n";
ptr = ptr-> next;
}
}
void read()
{
// reads from file database.txt
// keeps reading till end of file.
// stores the data in the currect
linked list.
// you can use display() to view
data that is read from database.txt.
ifstream fin("database.txt");
string id;
while (fin >> id) {
st* temp = new st;
st* temp1 = new st;
temp-> id = id;
fin.ignore();
fin.getline(temp-> name, 49,
'\n');
fin >> temp-> grade;
fin >> temp-> phone;
fin >> temp->
dateofbirth;
fin.ignore();
fin.getline(temp->address, 99,
'\n');
// Head of linked list is
null
if (hptr ==
0)
{
temp-> next = hptr;
hptr = temp;
}
else
{
temp1 = hptr;
while (temp1-> next)
temp1 = temp1->
next;
temp-> next = temp1-> next; //NULL
temp1-> next = temp;
}
}
}
void logo()
{
system("COLOR 0E");
cout << "\n\n\n\n";
cout<<
"\t\t======================================== = " <<
endl;
string hello = "\n\n\t\t WELCOME TO
STUDENT MANAGMENT SYSTEM ";
int x = 0;
while (hello[x] != '\0') {
cout << hello[x];
if (hello[x] != ' ' && hello[x] != '\n')
Sleep(50);
x++;
};
cout << "\n\n\t\t======================================== = "
<< endl;
cout << "\n";
system("pause");
system("COLOR 07");
system("cls");
}
-------------------------------------------
Output(After exit then restart application and press 5)
|Student ID.
| Name
| Grade
| Phone number
| Date of birth
| Address
------------------------------------------ -
2
Mia Mark
A
457896
05/05/2001
#403,block 3,RTSD
------------------------------------------------ -
Do you wants another operation(y/n)? : n
in this coding please add an address for the student to enter... note that this coding use linked list and a file text t...
in this coding please add an address for the student to enter... note that this coding use linked list and a file text to store its data ...Please make sure the address will work with all the functions below..to check whether your coding is correct after you finished adding a new dummy student data and its information close the program and reopen it and choose the option 5 ... I've tried adding an address before but an error occurred when...
Q) Modify the class Linked List below to make it a Doubly Linked List. Name your class DoublyLinkedList. Add a method addEnd to add an integer at the end of the list and a method displayInReverse to print the list backwards. void addEnd(int x): create this method to add x to the end of the list. void displayInReverse(): create this method to display the list elements from the last item to the first one. Create a main() function to test...
Using Python. 3) Create a single-linked list (StudentList) where the data in the link is an object of type pointer to Student as defined below. Note that you need to store and pass a pointer of type Student so that you do not create duplicate objects. Test your list with the provided program. You will find example code for a single-linked list of integers in Moodle that you can base your solution on. For your find methods, you can either...
Based on this program modify the source code so that it will able to save the student record into a database txt and able to display and modify from a database txt as well. you will also need to able to modify the code so it will accept name such as "john kenny " and the progrom should also ask for the student id number. #include<iostream> #include<stdlib.h> using namespace std; struct st { int roll; char name[50]; char grade; struct...
Add additional information to the student class below such as name, address, major, and contact information along with all the getters and setters (methods) needed to access all data. Submit your code along with a sample run of your program. Comment all your code. Cite any sources of information you use. Write a note on the process of completing the assignment in a Microsoft Word document. // ShowStudent.java // client to test the Student class class ShowStudent { public static...
Add additional information to the student class below such as name, address, major, and contact information along with all the getters and setters (methods) needed to access all data. Submit your code along with a sample run of your program. Comment all your code. Cite any sources of information you use. Write a note on the process of completing the assignment in a Microsoft Word document. // ShowStudent.java // client to test the Student class class ShowStudent { public static...
I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student { private String name; private double gpa; private int idNumber; public Student() { this.name = ""; this.gpa = 0; this.idNumber = 0; } public Student(String name, double gpa, int idNumber) { this.name = name; this.gpa = gpa; this.idNumber = idNumber; } public Student(Student s)...
Files given in this assignment (right-click on the file to download) Assignment7.cpp (need to complete) Student.h (Given. Just use it, don't change it!) Student.cpp (Partially filled, need to complete) 1. Assignment description In this assignment, you will write a simple class roster management system for ASU CSE100. Step #1: First, you will need to finish the design of class Student. See the following UML diagram for Student class, the relevant header file (class declaration) is given to you as Student.h,...
C++. Please note the BOLDED ITEMS. You will create a simple linked structure. You will use a simple node that has a pointer to a Node. The data for the Node will be a single data member of type char. You will build a structure where the last node you add will point to the first node created, i.e. it will be a circular linked structure. You will create a program that stores characters provided by the user, stored in...
Please answer in C++ Derive a class called Queue from the linked list described in Assignment 2 (list of Dates). This means the Queue class will inherit all the properties (data and functions) of the linked list. But, since a queue allows pushing only at the back and popping at the front of the list, you will need to prevent the addition in the front and removal at the back. To do this, you must derive the Queue class in...