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...
Question 1: Write a C program that stores student information in structure and display it. Question...
Question 1: Write a C program that stores student information in structure and display it. Question 2: In addition to the first question, you are expected to create one more structure for courses. Then, structures must be filled by user inputs. After filling your structures, you will let user to get any student enroll to any course from the course list. Hint: To achieve these steps, you must use pointer in your student structure to link it to course structure.
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>...
Assignment #4 – Student Ranking : In this assignment you are going to write a program...
Assignment #4 – Student Ranking : In this assignment you are going to write a program that ask user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’...
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*...
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...
WRITE C++ PROGRAM FOR 1,2,3,4 PARTS of question, DO ADD COOMENTS AND DISPLAY THE OUTPUT OF...
WRITE C++ PROGRAM FOR 1,2,3,4 PARTS of question, DO ADD COOMENTS AND DISPLAY THE OUTPUT OF A RUNNING COMPILER QUESTION: 1) Fibonacci sequence is a sequence in which every number after the first two is the sum of the two preceding ones. Write a C++ program that takes a number n from user and populate an array with first n Fibonacci numbers. For example: For n=10 Fibonacci Numbers: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 2): Write...
Use the Donor database attached to the assignment answer the following: Question 1: Create a block...
Use the Donor database attached to the assignment answer the following: Question 1: Create a block to retrieve and display pledge and payment information for a specific donor. For each pledge payment from the donor, display the pledge ID, pledge amount, number of monthly payments, payment date, and payment amount. The list should be sorted by pledge ID and then by payment date. For the first payment made for each pledge, display “first payment” on that output row. 2 marks...
Please do it in Python Write the simplest program that will demonstrate iteration vs recursion using...
Please do it in Python Write the simplest program that will demonstrate iteration vs recursion using the following guidelines - Write two primary helper functions - one iterative (IsArrayPrimeIter) and one recursive (IsArrayPrimeRecur) - each of which Take the array and its size as input params and return a bool. Print out a message "Entering <function_name>" as the first statement of each function. Perform the code to test whether every element of the array is a Prime number. Print out...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT