Related questions
CPP File
#include "result.h"
#include "Date.h"
Result::Result()
{
m_name = "";
m_unitID = "";
m_credits = 0;
m_mark = 0.0;
m_day = 0;
m_month = "";
m_year = 0;
}
Result::Result( string name, string id,unsigned credits, double M , unsigned d, string m, unsigned y)
{
m_name = name;
m_unitID = id;
m_credits = credits;
m_mark = M;
m_day = d;
m_month = m;
m_year = y;
}
istream & operator >>( istream & input, Result & RE)
{
string strInput;
getline(input,strInput, ',');
RE.SetUnitID(strInput);
getline(input, strInput, ',');
RE.SetName(strInput);
getline(input, strInput, ',');
RE.SetCredits(stoi(strInput));
getline(input, strInput, ',');
RE.SetMark(stod(strInput));
getline(input,strInput, ',');
RE.SetDay(stoi(strInput));
getline(input, strInput, ',');
RE.SetMonth(strInput);
getline(input, strInput, ',');
RE.SetYear(stoi(strInput));
getline(input, strInput, ',');
return input;
}
ostream & operator <<( ostream & os,const Result & RE )
{
string unitID;
string name;
string month;
double mark;
RE.GetUnitID(unitID);
RE.GetName(name);
RE.GetMonth(month);
RE.GetMark(mark);
os << " Unit ID: " << unitID << '\n'
<< " Unit Name: " << name << '\n'
<< " Credits: " << RE.GetCredits() << '\n'
<< " Mark: " << mark << '\n'
<< " Date: " << RE.GetDay() << " " << month << " " << RE.GetYear() << '\n';
return os;
}
Header File
#ifndef RESULT_H
#define RESULT_H
#include <iostream>
#include <string>
using namespace std;
const unsigned UnitNameSize = 40;
class Result {
public:
Result();
Result( std::string (nam), string id, unsigned credits , double M, unsigned d, string m, unsigned y);
// Construct a course from a name, section letter,
// and number of credits.
void GetName (string &name) const;
void SetName(const string &name);
void GetUnitID(string &id) const;
void SetUnitID(const string &id);
unsigned GetCredits() const;
void SetCredits(unsigned credits);
double GetMark() const;
void SetMark(double M);
unsigned GetDay() const;
void SetDay(unsigned d);
void GetMonth(string &m) const;
void SetMonth(string &m);
unsigned GetYear() const;
void SetYear(unsigned y);
// These operators have been made friends. They have
// privileged access to class internals.
// Very useful for debugging the class, but not very good for class design.
// We will keep using it for now but you will have a chance in a later lab
// to redesign this class.
friend ostream & operator <<( ostream & os, const Result & RE );
friend istream & operator >>( istream & input, Result & RE );
private:
string m_name; // course name, C style string. not a C++ string object
string m_unitID; // section (letter) can be enrolment mode
int m_credits; // number of credits
double m_mark; // marks
int m_day; // day of the date
string m_month; //month of the date
int m_year; // year of the date
};
void Result::GetName (string &name) const
{
name = m_name;
}
void Result::SetName(const string &name)
{
m_name = name;
}
void Result::GetUnitID(string &id) const
{
id = m_unitID;
}
void Result::SetUnitID(const string &id)
{
m_unitID = id;
}
unsigned Result::GetCredits() const
{
return m_credits;
}
void Result::SetCredits(unsigned credits)
{
m_credits = credits;
}
double Result::GetMark() const
{
return m_mark;
}
void Result::SetMark(double M)
{
m_mark = M;
}
unsigned Result::GetDay() const
{
return m_day;
}
void Result::SetDay(unsigned d)
{
m_day = d;
}
void Result::GetMonth(string &m) const
{
m = m_month;
}
void Result::SetMonth(string &m)
{
m_month = m;
}
unsigned Result::GetYear() const
{
return m_year;
}
void Result::SetYear(unsigned y)
{
m_year = y;
}
after implementing this code in an attempt to let the program read an input file with the method getline, I came across an error that says "error: no matching function for call to 'Result: : GetMark(double&) const'"
I need the body of the methods to be in the CPP file and only the method and class declaration to be in the .H file only. i have multiple other files that I cant post here but it all works together.
Step by stepSolved in 2 steps
- Dice_Game.cpp #include <iostream>#include "Die.h" using namespace std; // a struct for game variablesstruct GameState { int turn = 1; int score = 0; int score_this_turn = 0; bool turn_over = false; bool game_over = false; Die die;}; // declare functionsvoid display_rules();void play_game(GameState&);void take_turn(GameState&);void roll_die(GameState&);void hold_turn(GameState&); int main() { display_rules(); GameState game; play_game(game);} // define functionsvoid display_rules() { cout << "Dice Game Rules:\n" << "\n" << "* See how many turns it takes you to get to 20.\n" << "* Turn ends when you hold or roll a 1.\n" << "* If you roll a 1, you lose all points for the turn.\n" << "* If you hold, you save all points for the turn.\n\n";} void play_game(GameState& game) { while (!game.game_over) { take_turn(game); } cout << "Game...arrow_forward//main.cpp #include "Person.h"#include "Seller.h"#include "Powerseller.h"#include <iostream>#include <list>#include <fstream>#include <string> using namespace std; void printMenu();void printSellers(list<Seller*> sellers);void checkSeller(list<Seller*> sellers);void addSeller(list<Seller*> sellers);void deleteSeller(list<Seller*> &sellers); int main() { list<Seller*> sellers; ifstream infile; infile.open("sellers.dat"); if (!infile) { cerr << "File could not be opened." << endl; exit(1); } char type; while (!infile.eof()) { infile >> type; if (type == 'S') { Seller* newseller = new Seller; newseller -> read(infile); sellers.push_back(newseller); } if (type == 'P') { Powerseller* newpowerseller = new Powerseller; newpowerseller -> read(infile); sellers.push_back(newpowerseller); } } infile.close();...arrow_forwardC++ Programmingarrow_forward
- Question 1: break phrase Problem statement Breaking a string into two parts based on a delimiter has applications. For example, given an email address, breaking it based on the delimiter "@" gives you the two parts, the mail server's domain name and email username. Another example would be separating a phone number into the area code and the rest. Given a phrase of string and a delimiter string (shorter than the phrase but may be longer than length 1), write a C++ function named break_string to break the phrase into two parts and return the parts as a C++ std::pair object (left part goes to the "first" and right part goes to the "second"). Do the following Write your algorithm as code comments. I recommend to follow UMPIRE technique Implement your functionarrow_forward// EmployeeBonus2.cpp - This program calculates an employee's yearly bonus. #include <iostream> #include <string> using namespace std; int main() { // Declare and initialize variables. string employeeFirstName; string employeeLastName; double employeeSalary; int employeeRating; double employeeBonus; const double BONUS_1 = .25; const double BONUS_2 = .15; const double BONUS_3 = .10; const double NO_BONUS = 0.00; const int RATING_1 = 1; const int RATING_2 = 2; const int RATING_3 = 3; // This is the work done in the housekeeping() function // Get user input cout << "Enter employee's first name: "; cin >> employeeFirstName; cout << "Enter employee's last name: "; cin >> employeeLastName; cout << "Enter employee's yearly salary: "; cin >> employeeSalary; cout << "Enter employee's performance rating: "; cin >> employeeRating; // This is...arrow_forwardCPP File #include "result.h"#include "Date.h" Result::Result(){m_name = "";m_unitID = "";m_credits = 0;m_mark = 0.0;m_day = 0;m_month = "";m_year = 0;} Result::Result( string name, string id,unsigned credits, double M , unsigned d, string m, unsigned y){m_name = name;m_unitID = id;m_credits = credits;m_mark = M;m_day = d;m_month = m;m_year = y;} istream & operator >>( istream & input, Result & RE){string strInput; getline(input,strInput, ','); RE.SetUnitID(strInput);getline(input, strInput, ','); RE.SetName(strInput);getline(input, strInput, ','); RE.SetCredits(stoi(strInput));getline(input, strInput, ','); RE.SetMark(stod(strInput));getline(input,strInput, ','); RE.SetDay(stoi(strInput));getline(input, strInput, ','); RE.SetMonth(strInput);getline(input, strInput, ','); RE.SetYear(stoi(strInput));getline(input, strInput, ','); return input;} ostream & operator <<( ostream & os,const Result & RE ){string unitID;string name;string month;double mark;...arrow_forward
- 16 Type the correct answer in the box. Use numerals instead of words. If necessary, use / for the fraction bar. var num2 = 32; var num1 = 12; var rem=num2 % num1; while(rem> 0) { num2 = num1; num1 = rem; rem =num2 9% num1; document.write(num1): The output of the document.write statement at the end of this block is Reset Next m. All rights reserved. 5896arrow_forwardC++ formatting please Write a program (not a function) that reads from a file named "data.csv". This file consists of a list of countries and gold medals they have won in various Olympic events. Write to standard out, the top 5 countries with the most gold medals. You can assume there will be no ties. Expected Output: 1: United States with 1022 gold medals 2: Soviet Union with 440 gold medals 3: Germany with 275 gold medals 4: Great Britain with 263 gold medals 5: China with 227 gold medalsarrow_forwardCommand Program Create a program that allows you to view and edit the sales amounts for each month of the current year. This program is required to use commands add, view, totals, edit, and exit. The program should use a list to store the sales data for each month with the three-letter abbreviation for the month (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, and Dec) to use as the key for each item. When the program starts, it should read the sales data inserted from the user. If the user edits the sales data, the program should edit the data If the user selects total, then the program should calculate the total sales and average monthly sales. Use functions to view sales, edit sales, calculate total, and calculate average. Please use all commands, and thank you in advance.arrow_forward
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education