Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please Make the following program in c++ as well as a development diary explained below. Project Description You are to implement a program scheduling a

Please Make the following program in c++ as well as a development diary explained below.

Project Description

You are to implement a program scheduling a doctor's daily schedule.

The list of requirements and constraints for the system are as follows:

The system will be used to manage grades of various students in a class The name of each student is unique and can be used to locate the information on a specific patient or time slot. User can print all grade information.

Code organization

Read the provided files below for detailed instructions on each class, and class members!

main.cpp

The main entry point of the executable. Set up the app class and run it. Provided file, do not modify!

Grade Class

The class to handle information of a single grade (one grade per student)

Gradebook Class

The class to manage grades

TextMenuApp Class

The main application class the drives a text menu based program. When reading in the student's name, make sure you handle the getline after extraction problem! Find the reference here (I put the files below)

makefile

The makefile is provided. Do not modify!

Implementation Notes

You may run the main-linux under Linux or WSL to try how the program works. All header files are provided. They provided the information about that needs to be implemented. Do not modify them. Make the corresponding cpp files as needed. Follow the file naming convention. You can run make or make main to compile your app and execute using ./main A makefile rule named test is provided and you can run it using make test to run the provided tests on the Grade and GradeBook classes. Run make testrun to reproduce the sample run shown in the instruction.

Development Diary

For this project, you must complete the following tasks in the order that they are described:

List out a set of steps that you will take to implement your solution to the problem. Each step refers to an increment of the program that you will be creating. It is recommended to complete the implementation of a single logical unit (a class, a method, a module/file, etc.) per step.

Keep track of your work as you implement the program, log the tasks you completed, and issues encountered along the way. For example - Friday 02/26: completed class X, encountered some issues

Once you have finished implementing your solution, reflect on the process that you followed. For example, did you have to deviate from your plan? What challenges have your encountered and how you solved it.

Your responses to these tasks should be submitted as a text or word document called diary.txt/diary.docx and include it in your zip file.

Be concise but informative. Use bullet points rather than paragraphs.

Provided Files

text-menu-app.hpp

#ifndef TEXT_MENU_APP_HPP

#define TEXT_MENU_APP_HPP

#include "gradebook.hpp"

#include

class TextMenuApp {

GradeBook &gradeBook;

public:

// Provided constructor

// initialize the gradeBook instance variable

explicit TextMenuApp(GradeBook &gradeBook) :

gradeBook(gradeBook) {};

// drives the main logic of the text menu app

void run(); }; #endif // TEXT_MENU_APP_HPP

main.cpp

#include "grade.hpp"

#include "gradebook.hpp"

#include "text-menu-app.hpp"

int main() {

// create initial data of a sample gradebook

GradeBook gradeBook("COP 3014");

gradeBook.addGrade("John Smith", 90);

gradeBook.addGrade("Laura Johnson", 83);

gradeBook.addGrade("Josh Brown", 77);

// create and run the text menu based app

TextMenuApp menu(gradeBook);

menu.run();

return EXIT_SUCCESS; }

gradebook.hpp

#ifndef GRADEBOOK_HPP

#define GRADEBOOK_HPP

#include "grade.hpp" #include

class GradeBook {

std::string courseName;

Grade grades[40];

// hold 40 grades at most, assuming it is enough

int count = 0;

public:

// default constructor

GradeBook();

// parameterized constructor to set the initial values of

// all instance variables

GradeBook(const std::string &courseName);

// getter of the count of students

int getCount() const;

// getter of the course name

std::string getName() const;

// add a new grade

// do not worry about the size limit

void addGrade(const std::string &name, double grade);

// search the grade by student's name

// return -1 if not found

int searchStudent(const std::string &name) const;

// print the student's info providing a valid index

// assuming that the index is valid (get from the search)

// ask the Grade object to print

void printStudent(int studentIndex) const;

// print a summary of the course like:

// Gradebook of course COP 3014

// Name: John Smith | Grade: 90.0

// Name: Laura Johnson | Grade: 83.0

// Name: Josh Brown | Grade: 77.0

// ask each Grade object to print itself

void print() const;

};

#endif // GRADEBOOK_HPP

grade.hpp

#ifndef GRADE_HPP

#define GRADE_HPP

#include

class Grade {

std::string studentName;

double grade;

public:

// default constructor

Grade();

// parameterized constructor to set the initial values of

// all instance variables

Grade(const std::string &name, double grade);

// getter of the student's name

std::string getName() const;

// getter of the grade

double getGrade() const;

// print the grade info in the format like:

// Name: Jerry Williams | Grade: 78.0

// should display one decimal place

void print() const;

};

#endif // GRADE_HPP

test.cpp

#include "grade.hpp"

#include "gradebook.hpp"

#include #include

#include

using namespace std;

bool isClose(double v1, double v2) {

double epsilon = 1e-4;

return fabs(v1 - v2) < epsilon;

}

void testGrade() {

cout << "Testing grade class" << endl;

Grade grade;

assert(grade.getName().empty());

Grade grade1("new name", 90);

assert(grade1.getName() == "new name");

assert(isClose(grade1.getGrade(), 90));

grade1.print();

}

void testGradeBook() {

cout << "Testing grade book class" << endl;

GradeBook gradeBook("COP3014");

gradeBook.addGrade("John Smith", 92);

assert(gradeBook.getName() == "COP3014"); assert(gradeBook.searchStudent("invalid student") == -1); assert(gradeBook.searchStudent("John Smith") == 0);

gradeBook.print();

}

int main() {

testGrade();

testGradeBook();

cout << "All test passed!" << endl;

return EXIT_SUCCESS;

}

makefile

SHELL=/bin/bash

TARGETS=main test

CXX=g++

FLAGS=-std=c++11 -Wall

RM=rm -rf

.PHONY: clean

# Target rules

main: main.o text-menu-app.o gradebook.o grade.o

$(CXX) -o $@ $^ test: test.o gradebook.o grade.o $(CXX) -o $@ $^

./test

# General compilation rules

%.o: %.cpp

$(CXX) $(FLAGS) -c $<

# Rule to test run your code with the exact same input used in the sample run

testrun: main

echo -e "1 2 Bad Name John Smith 3 Jerry Williams 123 -5 78 1 4 " | ./main

clean: $(RM) .o $(TARGETS).gc* *.dSYM

**Provided Sample Run**

1. Print all grades; 2. Print a single grade; 3. Add a new grade; 4. Exit. Please choose an option(1-4): 1 Gradebook of course COP 3014 Name: John Smith | Grade: 90.0 Name: Laura Johnson | Grade: 83.0 Name: Josh Brown | Grade: 77.0 1. Print all grades; 2. Print a single grade; 3. Add a new grade; 4. Exit. Please choose an option(1-4): 2 Please input the student name: Bad Name Name not found! Please input an existing name Please input the student name: John Smith Name: John Smith | Grade: 90.0 1. Print all grades; 2. Print a single grade; 3. Add a new grade; 4. Exit. Please choose an option(1-4): 3 Please input the name of the student: Jerry Williams Please input the grade: 123 The grade should be with in the range from 0 to 100 Please input the grade: -5 The grade should be with in the range from 0 to 100 Please input the grade: 78 1. Print all grades; 2. Print a single grade; 3. Add a new grade; 4. Exit. Please choose an option(1-4): 1 Gradebook of course COP 3014 Name: John Smith | Grade: 90.0 Name: Laura Johnson | Grade: 83.0 Name: Josh Brown | Grade: 77.0 Name: Jerry Williams | Grade: 78.0 1. Print all grades; 2. Print a single grade; 3. Add a new grade; 4. Exit. Please choose an option(1-4): 4 Thank you for using the app!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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