Question

Write C++ program to create a student record include a student ID, first name, nickname, course,...

Write C++ program to create a student record include a student ID, first name, nickname, course, subject, and subject marks.

Task:

Create a function to insert a number of students in the record.

Create a function to print all student information by a table.

Create a function to print all student information that they're in a specific course chosen by user input.

Create a function to search for a student by student ID and print student information.

Create a function to search for a student by student ID and edit student marks bu user input.

Create a function to find the Average marks in the specific course chosen by user input.

Create a function to increase student marks 10% for students whose marks is less than marks chosen by user input.

Homework Answers

Answer #1

CODE:

OUTPUT:

RAW CODE:

#include<iostream>
using namespace std;
struct student{
        string ID;
        string first_name;
        string nick_name;
        string course;
        float marks;
        student *next;
}*head = NULL;
void insert(string id,string f_name,string n_name,string course,float marks){
        struct student *temp = new(struct student);
        temp->ID = id;
        temp->first_name = f_name;
        temp->nick_name = n_name;
        temp->course = course;
        temp->marks = marks;
        temp->next = NULL;
        if(head==NULL){
                temp->next = head;
                head = temp;
        }
        else{
                struct student *trav = head;
                while(trav->next!=NULL){
                        trav = trav->next;
                }
                trav->next = temp;
        }
}
void print_students(){
        cout << endl;
        struct student *trav = head;
        cout << "Students in the Recordes:\n";
        if(head==NULL){
                cout << "There is no student in the record\n";    
        }
        else{
                struct student *trav = head;
                cout << "ID\tFirst Name\tNick Name\tcourse\tmarks\n";
                while(trav!=NULL){
                        cout << trav->ID << "\t" << trav->first_name << "\t\t" << trav->nick_name << "\t\t" << trav->course << "\t" << trav->marks << endl;
                        trav = trav->next;
                }
        }
}
void course_chosen(string course){
        cout << endl;
        struct student *trav = head;
        cout << "Student information that they're in a specific course:\n";
        cout << "ID\tFirst Name\tNick Name\tcourse\tmarks\n";
        while(trav!=NULL){
                if (trav->course == course){
                        cout << trav->ID << "\t" << trav->first_name << "\t\t" << trav->nick_name << "\t\t" << trav->course << "\t" << trav->marks << endl;
                }
                trav = trav->next;
        }
}
void search(string id){
        cout << endl;
        struct student *trav = head;
        cout << "Student information with given student id:\n";
        cout << "ID\tFirst Name\tNick Name\tcourse\tmarks\n";
        while(trav!=NULL){
                if (trav->ID == id){
                        cout << trav->ID << "\t" << trav->first_name << "\t\t" << trav->nick_name << "\t\t" << trav->course << "\t" << trav->marks << endl;
                        break;
                }
                trav = trav->next;
        }
}
void edit_marks(string id,float marks){
        cout << endl;
        struct student *trav = head;
        while(trav!=NULL){
                if (trav->ID == id){
                        trav->marks = marks;
                        break;
                }
                trav = trav->next;
        }
}
void average_course(string course){
        cout << endl;
        struct student *trav = head;
        float sum = 0;
        int count = 0;
        while(trav!=NULL){
                if (trav->course == course){
                        sum += trav->marks;
                        count += 1;
                }
                trav = trav->next;
        }
        float average= sum/count;
        cout << "Average of " << course << " course is " << average << "\n";
}
void increase_marks(float marks){
        struct student *trav = head;
        while(trav!=NULL){
                if (trav->marks < marks){
                        trav->marks += trav->marks * ((float)10/100);
                }
                trav = trav->next;
        }
}
int main()
{
        int n;
        string id,f_name,n_name,course;
        float marks;
        cout << "Enter number of students: ";
        cin >> n;
        cout << "\n";
        for (int i = 0; i < n; ++i)
        {
                cout << "Enter ID:";cin >> id;
                cout << "Enter First name: ";cin >> f_name;
                cout << "Enter nick name: ";cin >> n_name;
                cout << "course: ";cin >> course;
                cout << "marks: ";cin >> marks;
                cout << "\n";
                insert(id,f_name,n_name,course,marks);
        }


        print_students();
        cout << "\n";

        cout << "Chose course to print all students: " ;
        cin >> course;
        course_chosen(course);
        cout << "\n";

        cout << "Chose ID to print student information: " ;
        cin >> id;
        search(id);
        cout << "\n";

        cout << "Chose ID to change marks: " ;
        cin >> id;
        cout << "Enter marks: ";
        cin >> marks;
        edit_marks(id,marks);
        cout << "\n";

        cout << "Chose course to average marks: " ;
        cin >> course;
        average_course(course);
        cout << "\n";

        cout << "Chose marks to increase 10% : " ;
        cin >> marks;
        increase_marks(marks);
        cout << "\n";

        print_students();
        return 0;
}

NOTE:
If You have any doubts feel free to comment in comment section.
DO VOTE(LIKE).

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
C Programming: Create a struct named “Student” along with 3 properties, Name, ID, Score Choosing the...
C Programming: Create a struct named “Student” along with 3 properties, Name, ID, Score Choosing the correct data type for each property. Once the program is running, it will check if the student.bin file is exist and if it is not exist, the program will ask user to enter three student information and save them to file student.bin . If the file is exist, read the second student information and print it in console.
Create a student record management system With JAVA using linked list and queue using Java language...
Create a student record management system With JAVA using linked list and queue using Java language and (oracle or any) database to save files and GUI Java swing to create background The program will have the following properties: A. Register students ( assume each students has ID, first name, last name and middle name) B. Register students with courses ( course no ,course title chr ) C. Able to maintain grade on which course they are registered D. Searches students...
4. Write a C++ program that reads Id, name, and GPA of each of n students...
4. Write a C++ program that reads Id, name, and GPA of each of n students in a course, where n is an integer number between 10 and 30 (inclusive). Use bubble sorting to display the list of students in an ascending order according to the student name.
Create a class called Student. Include the following instance variables: name, address, phone, gpa Create all...
Create a class called Student. Include the following instance variables: name, address, phone, gpa Create all of the methods required for a standard user defined class: constructors, accessors, mutators, toString, equals Create the client for testing the Student class (5 points extra credit) Create another class called CourseSection (20 points extra credit) Include instance variables for: course name, days and times course meets (String), description of course, student a, student b, student c (all of type Student) Create all of...
In c++ create a class to maintain a GradeBook. The class should allow information on up...
In c++ create a class to maintain a GradeBook. The class should allow information on up to 3 students to be stored. The information for each student should be encapsulated in a Student class and should include the student's last name and up to 5 grades for the student. Note that less than 5 grades may sometimes be stored. Your GradeBook class should at least support operations to add a student record to the end of the book (i.e., the...
create a complete C++ program that will read from a file, "studentInfo.txt", the user ID for...
create a complete C++ program that will read from a file, "studentInfo.txt", the user ID for a student (first letter of their first name connected to their last name i.e. jSmith). Next it will need to read three integer values that will represent the 3 e xam scores the student got for the semester. Once the values are read and stored in descriptive variables it will then need to calculate a weighted course average for that student. Below is an...
write a program that automates the process of generating the final student report for DC faculty...
write a program that automates the process of generating the final student report for DC faculty considering the following restrictions. Consider declaring three arrays for processing the student data: studID studName studGrade The student ID is a random number generated by the 5-digit system in the range of (10000 - 99999). Create a function to assign the student ID generated in an array of numbers. Consider the following to generate the random number: Add the libraries: #include <stdlib.h> #include <ctime>...
This program is in C++: Write a program to allow the user to: 1. Create two...
This program is in C++: Write a program to allow the user to: 1. Create two classes. Employee and Departments. The Department class will have: DepartmentID, Departmentname, DepartmentHeadName. The Employee class will have employeeID, emploeename, employeesalary, employeeage, employeeDepartmentID. Both of the above classes should have appropriate constructors, accessor methods. 2. Create two arrays . One for Employee with the size 5 and another one for Department with the size 3. Your program should display a menu for the user to...
In this lab, you will write a program that creates a binary search tree based on...
In this lab, you will write a program that creates a binary search tree based on user input. Then, the user will indicate what order to print the values in. **Please write in C code** Start with the bst.h and bst.c base code provided to you. You will need to modify the source and header file to complete this lab. bst.h: #ifndef BST_H #define BST_H typedef struct BSTNode { int value; struct BSTNode* left; struct BSTNode* right; } BSTNode; BSTNode*...
Using C# Create an Employee class with five fields: first name, last name, workID, yearStartedWked, and...
Using C# Create an Employee class with five fields: first name, last name, workID, yearStartedWked, and initSalary. It includes constructor(s) and properties to initialize values for all fields. Create an interface, SalaryCalculate, class that includes two functions: first,CalcYearWorked() function, it takes one parameter (currentyear) and calculates the number of year the worker has been working. The second function, CalcCurSalary() function that calculates the current year salary. Create a Worker classes that is derived from Employee and SalaryCalculate class. In Worker...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT