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...
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...
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;...
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: ...
#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:" <<...
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...
Am I getting this error because i declared 'n' as an int, and then asking it to make it a double? This is the coude: #include "stdafx.h" #include <iostream> #include <fstream> #include <string> #include <algorithm> #include <vector> using namespace std; void sort(double grades[], int size); char calGrade(double); int main() { int n; double avg, sum = 0;; string in_file, out_file; cout << "Please enter the name of the input file: "; cin >> 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,...
Requirements: Finish all the functions which have been declared inside the hpp file. Details: string toString(void) const Return a visible list using '->' to show the linked relation which is a string like: 1->2->3->4->5->NULL void insert(int position, const int& data) Add an element at the given position: example0: 1->3->4->5->NULL instert(1, 2); 1->2->3->4->5->NULL example1: NULL insert(0, 1) 1->NULL void list::erase(int position) Erase the element at the given position 1->2->3->4->5->NULL erase(0) 2->3->4->5->NULL //main.cpp #include <iostream> #include <string> #include "SimpleList.hpp" using std::cin; using...