Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question: I am getting errors in this code. What am I doing wrong here? How do I get the code to count the coins in

Question:

I am getting errors in this code. What am I doing wrong here?

How do I get the code to count the coins in my .csv file?

Below is the code and an attachment of my errors:

#include #include #include #include #include #include #include #include using namespace std; const string myFile = ("Coins.csv");

#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include "doctest.h"

class Crypto {

struct Coins { int rank; string name; string symbol; double marketCap; };

fstream file; vectorarr; fstream myFile;

public: bool OpenFile(string fileName) { myFile.open(fileName); if (!myFile.is_open()) { cout

int ParseCurrencies() { vector row; string line, word; vectorarr; fstream myFile; while (getline(myFile, line)) { row.clear(); stringstream str(line); while (getline(str, word, ',')) row.push_back(word); Coins temp; temp.rank = stoi(row[0]); temp.name = row[1]; temp.symbol = row[2]; temp.marketCap = stoi(row[3]); arr.push_back(temp); } cout

}

int CountCoinsStartingWithLetter(char a) { vector row;

string name; int cnt = 0; for (int i = 0; i

TEST_CASE("Testing the Crypto Coins Class") { Crypto cryptos; CHECK(cryptos.OpenFile("Coins.csv") == true); CHECK(cryptos.ParseCurrencies() == COUNT_COINS); CHECK(cryptos.CountCoinsStartingWithLetter('a') != 5); CHECK(cryptos.CountCoinsStartingWithLetter('a') == 6); CHECK(cryptos.CountCoinsStartingWithLetter('a') != 7);

}; ;

image text in transcribed

96 abs E0020 identifier "COUNT_COINS" is undefined A C26495 Variable 'Crypto::Coins::marketCap' is uninitialized. Always initialize a member variable (type.6). A C26495 Variable 'Crypto::Coins:rank' is uninitialized. Always initialize a member variable (type.6). C2065 'COUNT_COINS': undeclared identifier 31 31 96

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions

Question

What is the schedule for this project?

Answered: 1 week ago

Question

=+ Who do you think is right? Why?

Answered: 1 week ago