//Definition for updated file product.h can be written as
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <string>
using namespace std;
class product
{
private:
string productId;
string aisleId; //Definition for aisleId
float productPrice;
public:
product(void);
void setProductId(string);
void setProductPrice(float);
void setAisleId(string); //Definition for mutator function
string getProductId();
float getProductPrice();
string getAisleId(); //Definition for accessor function
void print();
void increasePriceby15Percent(); //Definition for increase price by
15 percent
};
//Definition for the updated file product.cpp can be written as
#include "product.h"
product::product(void)
{
productId = "--";
productPrice = 0.99f;
strcpy(aisleId,"-none-"); //Initializing the value of aisleId
}
void product::setProductId(string _productId)
{
productId = _productId;
}
void product::setProductPrice(float _productPrice)
{
if(_productPrice>=0.0) //Validate for non-negative values
produtcPrice = _productPrice;
else
cout<<"\nWrong input";
}
//Mutator method for aisleId
void product::setAisleId(string _aisleId)
{
strcpy(aisleId, _aisleId);
}
string product::getProductId()
{
return productId;
}
float product::getProductPrice()
{
return productPrice;
}
//Accessor function for aisleId
string product::getAisleId()
{
return aisleId;
}
void product::print()
{
cout << setprecision(2) << fixed;
cout << "id=" << productId << ", Price= " << productPrice << endl;
}
//function to increase price by 15 percent
void increasePriceBy15Percent()
{
productPrice = productPrice+(productPrice*0.15);
}
Contents? Introduction Existing code & UML UML Code Changes to be made to the program tester_with_mods.cpp...
Edit this C++ code to show the output as well.
#include<iostream>
#include<cstring>
using namespace std;
class Product {
private:
// private variables
int id_number;
char pDescription[40];
int mId;
double productPrice;
double productMarkUp;
int qty;
public:
// constructor
Product() {
id_number = 0;
strcpy_s(pDescription, "");
mId = 0;
productPrice = 0.0;
productMarkUp = 0.0;
qty = 0;
}
...
Write a C++ Program. You have a following class as a header file (dayType.h) and main(). #ifndef H_dayType #define H_dayType #include <string> using namespace std; class dayType { public: static string weekDays[7]; void print() const; string nextDay() const; string prevDay() const; void addDay(int nDays); void setDay(string d); string getDay() const; dayType(); dayType(string d); private: string weekDay; }; #endif /* // Name: Your Name // ID: Your ID */ #include <iostream>...
The following C++ code include 3 files: Patient.h, Patient.cpp and Main.cpp. The program basically creates and stores patient records. The original code has everything in a single .cpp file. I tried to divide the code in 3 parts (Patient.h, Patient.cpp and Main.cpp), but it is giving me errors. Patient.h #ifndef PATIENT_H #define PATIENT_H #include <string> #include "Patient.cpp" using namespace std; class Patient{ private : string firstname; string lastname; string location; static int cnt; int id; public : Patient(string, string, string);...
C++ -- Vector of Bank Accounts (15 pts) Please help! :( Use csegrid or Clion for this part Add on to the lab12a solution(THIS IS PROVIDED BELOW). You will add an overload operator function to the operator << and a sort function (in functions.h and functions.cpp) Print out the customer’s name, address, account number and balance using whatever formatting you would like Sort on account balance (hint: you can overload the < operator and use sort from the...
how can we change this c++ code to give the output: Product name: Fluffy Puff Marshmallows Price: $1.99 Fluffy Puff Marshmallows: $1.39 (with 30% discount) correct this code: #include <iostream> #include <string> using namespace std; int main() { string product; float price; cout << "Product name: "; cin >> product; cout << "Price: $"; cin >> price; cout << endl; cout << product << ": $" << price * 0.7 << " (with 30% discount)" << endl; return 0; }
previous assignment code /*C++ test program to test the classes, Animal, Mammal and Cat and print the results on console window.*/ //Main.cpp //include header files #include<iostream> //include Animal, Mammal and Cat header files #include "Animal.h" #include "Mammal.h" #include "Cat.h" using namespace std; int main() { //create Animal object Animal animal("Dog","Mammal",4); cout<<"Animal object details"<<endl; cout<<"Name: "<<animal.getName()<<endl; cout<<"Type: "<<animal.getType()<<endl; cout<<"# of Legs: "<<animal.getLegs()<<endl; cout<<endl<<endl; //create Cat object Cat cat("byssinian cat","carnivorous mammal",4,"short...
Greetings, everybody I already started working in this program. I just need someone to help me complete this part of the assignment (my program has 4 parts of code: main.cpp; Student.cpp; Student.h; StudentGrades.cpp; StudentGrades.h) Just Modify only the StudentGrades.h and StudentGrades.cpp files to correct all defect you will need to provide implementation for the copy constructor, assignment operator, and destructor for the StudentGrades class. Here are my files: (1) Main.cpp #include <iostream> #include <string> #include "StudentGrades.h" using namespace std; int...
C++
#include <iostream>
using namespace std;
bool checkinventoryid(int id)
{
return id > 0;
}
bool checkinventoryprice(float price)
{
return price > 0;
}
void endProgram()
{
system("pause");
exit(0);
}
void errorID(string str)
{
cout << "Invalid Id!!! " << str
<< " should be greater than 0" << endl;
}
void errorPrice(string str)
{
cout << "Invalid Price!!!" << str
<< " should be greater than 0" << endl;
}
int inputId()
{...
Please provide a multi lined pseudo code for the program below.....also it is giving me a build error? Could you possibly tell me how to fix the error too? #include <iostream> #include <string> using namespace std; class ship { public: string name; int year; ship(string n, int y) { name = n; year = y; } int getYear() { return year; } string getName() { return name; } void setYear(int y) { year = y; } void setName(string n) {...
Here is the code from the previous three steps:
#include <iostream>
using namespace std;
class Student
{
private:
//class variables
int ID;
string firstName,lastName;
public:
Student(int ID,string firstName,string lastName)
//constructor
{
this->ID=ID;
this->firstName=firstName;
this->lastName=lastName;
}
int getID() //getter method
{
return ID;
}
virtual string getType() = 0; //pure virtual function
virtual void printInfo() //virtual function to print basic details
of a student
{
cout << "Student type: " << getType() <<
endl;
cout << "Student ID: " << ID...