anyone help me seperate this into a header file (.h contains function and variable delcaration) and a implementation file (.cpp that contains the definitions for the functions and variables)
#include <iostream>
using namespace std;
#define MAXSIZE 100
class Grader{
private:
int my_Values[MAXSIZE];
int my_valuesSeenSoFar;
public:
Grader(){
my_valuesSeenSoFar = 0;
}
void addScore(int score){
my_Values[my_valuesSeenSoFar++] = score;
}
void addScores(int scores[], int size){
for(int i = 0; i < size; i++){
my_Values[my_valuesSeenSoFar++] = scores[i];
}
}
void clear(){
for(int i = 0; i < my_valuesSeenSoFar; i++) my_Values[i] =
0;
my_valuesSeenSoFar = 0;
}
int findBiggest() const{
int biggest = my_Values[0];
for(int i = 1; i < my_valuesSeenSoFar; i++){
if(my_Values[i] > biggest) biggest = my_Values[i];
}
return biggest;
}
int findSmallest() const{
int smallest = my_Values[0];
for(int i = 1; i < my_valuesSeenSoFar; i++){
if(my_Values[i] < smallest) smallest = my_Values[i];
}
return smallest;
}
};
int main(){
Grader g;
int d[5]= {99,70,85,93,84};
int e[4]= {100,81,60,91};
g.addScore(75);
g.addScore(82);
g.addScores(d, 5);
cout << "Best Score = " << g.findBiggest() <<
endl;
/// should give value 99
cout << "Worst Score = " << g.findSmallest() <<
endl;
/// should give value 70
g.clear();
g.addScore(50);
g.addScore(74);
g.addScores(e, 4);
cout << "Best Score = " << g.findBiggest() <<
endl;
/// should give value 100
cout << "Worst Score = " << g.findSmallest() <<
endl;
/// should give value 50
}
//Grader.h
#include <iostream>
using namespace std;
#define MAXSIZE 100
class Grader{
private:
int my_Values[MAXSIZE];
int my_valuesSeenSoFar;
public:
Grader();
void addScore(int score);
void addScores(int scores[], int size);
void clear();
int findBiggest()const;
int findSmallest()const;
};
-------------------------------------------
//Grader.cpp
#include"Grader.h"
Grader::Grader(){
my_valuesSeenSoFar = 0;
}
void Grader::addScore(int score){
my_Values[my_valuesSeenSoFar++] = score;
}
void Grader::addScores(int scores[], int size){
for(int i = 0; i < size; i++){
my_Values[my_valuesSeenSoFar++] = scores[i];
}
}
void Grader::clear(){
for(int i = 0; i < my_valuesSeenSoFar; i++) my_Values[i] = 0;
my_valuesSeenSoFar = 0;
}
int Grader::findBiggest() const{
int biggest = my_Values[0];
for(int i = 1; i < my_valuesSeenSoFar; i++){
if(my_Values[i] > biggest) biggest = my_Values[i];
}
return biggest;
}
int Grader::findSmallest() const{
int smallest = my_Values[0];
for(int i = 1; i < my_valuesSeenSoFar; i++){
if(my_Values[i] < smallest) smallest = my_Values[i];
}
return smallest;
}
--------------------------------------------
//main.cpp remains same, except including Grader.h header file,, still posting main.cpp and output
#include <iostream>
#include"Grader.h"
using namespace std;
int main(){
Grader g;
int d[5]= {99,70,85,93,84};
int e[4]= {100,81,60,91};
g.addScore(75);
g.addScore(82);
g.addScores(d, 5);
cout << "Best Score = " << g.findBiggest() << endl;
/// should give value 99
cout << "Worst Score = " << g.findSmallest() << endl;
/// should give value 70
g.clear();
g.addScore(50);
g.addScore(74);
g.addScores(e, 4);
cout << "Best Score = " << g.findBiggest() << endl;
/// should give value 100
cout << "Worst Score = " << g.findSmallest() << endl;
/// should give value 50
}
---------------------------------------------
//output
Best Score = 99 Worst Score = 70 Best Score = 100 Worst Score = 50
anyone help me seperate this into a header file (.h contains function and variable delcaration) and...
How to turn this file into a main.cpp, a header which contains the function declaration, and a implementation fiel containing the function definition ? #include<iostream> #include<string> #include<iomanip> using namespace std; #define NUM 1 #define MULT 4 void getPi(int iter); int main() { int it; cout << "Enter the number of iterations needed to find PI: "; cin >> it; while (it < 1) { cout << "Error!!! Iteration input should be positive." << endl;...
I have 2 issues with the C++ code below. The biggest concern is that the wrong file name input does not give out the "file cannot be opened!!" message that it is coded to do. What am I missing for this to happen correctly? The second is that the range outputs are right except the last one is bigger than the rest so it will not output 175-200, it outputs 175-199. What can be done about it? #include <iostream> #include...
c++ 1) Write a header file that contains the prototype for a function that takes two value parameters (both floats) and returns a single character output. The function name is “charIn”. We do not care what the function does at this point. (8) 2) Fix the Errors of the C++ program: a. #include <cmath> b. Void main(){cout<< “Math test”<<endl;//start math test c. Int i=10 int j=3 k=i%3 cout << “test of mod<<k<<endl d. Float d=0 float f=e/d cout << “div...
The function retrieveAt of the class arrayListType is written as a void function. Rewrite this function so that it is written as a value returning function, returning the required item. If the location of the item to be returned is out of range, use the assert function to terminate the program. note: please give all code in c++ below is the class and implementation(a test program would be helpful in determining how to use it): class arrayListType { public: ...
this is in my .cpp void Sequence::push_back(const value_type& value) { } this is in my .h under public typedef int value_type; void push_back(const value_type& v); this is the code i have to produce in my .cpp try { cout << "Testing push_back()" << endl; cout << "-------------------" << endl; Sequence data(3); data[0] = 100; data[1] = 200; data[2] = 300; data.push_back(400); data.push_back(500); ...
I need to update this C++ code according to these instructions.
The team name should be "Scooterbacks".
I appreciate any help!
Here is my code:
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
void menu();
int loadFile(string file,string names[],int jNo[],string
pos[],int scores[]);
string lowestScorer(string names[],int scores[],int size);
string highestScorer(string names[],int scores[],int size);
void searchByName(string names[],int jNo[],string pos[],int
scores[],int size);
int totalPoints(int scores[],int size);
void sortByName(string names[],int jNo[],string pos[],int
scores[],int size);
void displayToScreen(string names[],int jNo[],string pos[],int
scores[],int size);
void writeToFile(string...
#include <iostream> #include <fstream> using namespace std; //constants const int CAP = 100; //function prototypes bool openFile(ifstream &); void readData(ifstream &, int [], int &); void printData(const int [], int); void sum(const int[], int); void removeItem(int[], int &, int); int main() { ifstream inFile; int list[CAP], size = 0; if (!openFile(inFile)) { cout << "Program terminating!! File not found!" << endl; return -1; } //read the data from the file readData(inFile, list, size); inFile.close(); cout << "Data in file:" <<...
Can anyone help me with this one? I really appreciate it! Find and fix errors and Simplify the createGroups() function using only one loop instead of two #include using namespace std; const double NO_STU = 40; void createGroups(const string myClass[], int no_stu, string group1, string group2); void printList(const string [], int); int main() { int no_stu = 8; string myClass[NO_STU] = { "Linda", "Bob", "Mary", "Jo", "Tim", "Jamie", "Ann", "Tom" }; string group1[NO_STU % 2]; string group2[NO_STU % 2]; createGroups(no_stu,...