Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have the Bakery.H file and the main.cpp file already created and for some reason I am getting a error in line 1 3 1

I have the Bakery.H file and the main.cpp file already created and for some reason I am getting a error in line 131: cout "Total Cost: $" setw(12) getTotalCost() endl; stating "Total Cos'getTotalCost' was not declared in this scope
However it was declared. Can you please take a look at the program and tell me why it is telling me this?
Thank you in advance.
#include "Bakery.h"// Pulls from the header file
#include "main.cpp"// Pulls from main.cpp file in folder
#include
#include
#include // For changing console colors
using namespace std;
// Default constructor
Bakery::Bakery() : pastryID(0), quantity(0), price(0.0){}
// Parameterized constructor
Bakery::Bakery(int id, int quan, double pri) : pastryID(id), quantity(quan), price(pri){}
void Bakery::setPastryID(int id)
{
if (id >=0)
pastryID = id;
else // Using cerr for error messages throughout code.
cerr "Error: Pastry ID cannot be negative." endl;
}
void Bakery::setQuantity(int quan)
{
if (quan >=0)
quantity = quan;
else
cerr "Error: Quantity cannot be negative." endl;
}
void Bakery::setPrice(double pri)
{
if (pri >=0)
price = pri;
else
cerr "Error: Price cannot be negative." endl;
}
int Bakery::getPastryID() const
{
return pastryID;
}
int Bakery::getQuantity() const
{
return quantity;
}
// The function obtains the price per unit of the bakery items.
double Bakery::getPrice() const
{
return price; // Will return the price per unit of the items.
}
// Calculates the total of the bakery items
double Bakery::getTotalCost() const
{
// Caclualtes the total by multiplying the quantity with the price per unit.
return quantity * price;
}
void displayBakeryInventory(int pastryID, int quantity, double price)
{
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
// Program description
cout "
\t Welcome to the Bakery calculator!
";
cout "\t------------------------------------------------------
";
cout "***********************************************************
";
cout "* ~ Bakery Inventory ~ *
";
cout "**
";
cout "* This program will allow you to enter the pastry ID,*
";
cout "* the quantity and the price per pastry to be inventoried *
";
cout "* which will then tell you the total price of the item by *
";
cout "* bulk. *
";
cout "***********************************************************
";
// Changing letter color to red
SetConsoleTextAttribute(hConsole,12);
cout "
\t BAKERY INVENTORY
" endl;
cout "\t------------------------------------------------------
";
// Resetting letter color to white
SetConsoleTextAttribute(hConsole,15);
cout "Pastry ID: " setw(10) pastryID endl;
cout "Quantity:" setw(9) quantity endl;
cout "Price per unit: $" setw(9) fixed setprecision(2) price endl;
cout "Total Cost: $" setw(12) getTotalCost() endl;
// Changing letter color to red
SetConsoleTextAttribute(hConsole,12);
cout "........." endl;
// Resetting color to white
SetConsoleTextAttribute(hConsole,15);
}
image text in transcribed

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

Step: 3

blur-text-image

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

25 Vba Macros For Data Analysis In Microsoft Excel

Authors: Klemens Nguyen

1st Edition

B0CNSXYMTC, 979-8868455629

More Books

Students also viewed these Databases questions