Answer in C++! What is wrong with my code. The output with errors is included. Here's the Coin class definition. Complet

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Answer in C++! What is wrong with my code. The output with errors is included. Here's the Coin class definition. Complet

Post by answerhappygod »

Answer in C++! What is wrong with my code. The output with
errors is included.
Here's the Coin class definition. Complete the missing parts of
the implementation.
Answer In C What Is Wrong With My Code The Output With Errors Is Included Here S The Coin Class Definition Complet 1
Answer In C What Is Wrong With My Code The Output With Errors Is Included Here S The Coin Class Definition Complet 1 (238.71 KiB) Viewed 38 times
Here's the Coin class definition. Complete the missing parts of the implementation. class Coin { public: Coin(double value); -Coin(); double value() const; static int coins(); private: double m_value; static int num_coins; }; coin.cpp 1 #include <string> 2 #include "coin.h" 3 using namespace std; 4 int Coin:: num coins = 0; 5 Coin::Coin(double value) { 6 m value = value; 7 num_coins++; } 9 10 Coin: :-Coin() { 11 12 } 13 14 double Coin::value() const { 15 return m value; 16 } 17 18 int Coin::coins() 19 { 20 return num coins; 21 }

21 } Demo.cpp 1 #include <iostream> 2 #include <vector> 3 using namespace std; 4 5 #include "coin.h" 6 7 int main() 8 { 9 { 10 Coin a[] = { {.1}, {.25}, {.25} }; 11 cout << "#1 coins: " « Coin:: coins() << endl; 12 } 13 cout << "#2 coins: " « Coin::coins() << endl; 14 { 15 Coin a[] = { {.1}, {.25}, {.25}, {.05}, {.50}, {.01} }; 16 cout << "#3 coins: " « Coin::coins() << endl; 17 } 18 cout << "#4 coins: " « Coin::coins() << endl; 19 } CodeCheck Reset Testing Demo.cpp Actual Expected #1 coins: 3 #2 coins: 3 #3 coins: 9 #4 coins: 9 #1 coins: 3 #2 coins: 0 #3 coins: 6 #4 coins: 0 fail Score 0/1
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply