Question
Ex: If the input is: Pablo Picasso 1881 1973 Three Musicians 1921 the output is: Artist: Pablo Picasso (1881 to 1973) Title: Three Musicians, 1921
Ex: If the input is:
Pablo Picasso 1881 1973 Three Musicians 1921
the output is:
Artist: Pablo Picasso (1881 to 1973) Title: Three Musicians, 1921
We have he provided codes:
main.cpp
#include
int main() { int userYear; int userPrice; int userCurrentYear; Car myCar; cin >> userYear; cin >> userPrice; cin >> userCurrentYear; myCar.SetModelYear(userYear); myCar.SetPurchasePrice(userPrice); myCar.CalcCurrentValue(userCurrentYear); myCar.PrintInfo(); return 0; }
Car.cpp
#include
void Car::SetModelYear(int userYear){ modelYear = userYear; }
int Car::GetModelYear() const { return modelYear; }
// TODO: Implement SetPurchasePrice() function
// TODO: Implement GetPurchasePrice() function
void Car::CalcCurrentValue(int currentYear) { double depreciationRate = 0.15; int carAge = currentYear - modelYear; // Car depreciation formula currentValue = purchasePrice * pow((1 - depreciationRate), carAge); }
// TODO: Implement PrintInfo() function to output modelYear, purchasePrice, and // currentValue
Car.h
#ifndef CARH #define CARH
class Car { private: int modelYear; // TODO: Declare purchasePrice member (int) double currentValue; public: void SetModelYear(int userYear);
int GetModelYear() const; // TODO: Declare SetPurchasePrice() function // TODO: Declare GetPurchasePrice() function void CalcCurrentValue(int currentYear); // TODO: Declare PrintInfo() method to output modelYear, purchasePrice, and // currentValue };
#endif
17.11 LAB: Artwork label (classes and constructors) Make sure to use char arrays for all string data members. And use cstring functions. Given main(), complete the Artist class (in files Artist.h and Artist.cpp) with constructors to initialize an artist's information, get member functions, and a PrintInfo0 member function. The default constructor should initialize the artist's name to "unknown" and the years of birth and death to - 1 . Printinfo0 displays "Artist:", then a space, then the artist's name, then another space, then the birth and death dates in one of three formats: - (XXXX to FYY) if both the birth and death years are nonnegative - (XXXX to present) if the birth year is nonnegative and the death year is negative - (unknown) otherwise Complete the Artwork class (in files Artwork.h and Artwork.cpp) with constructors to initialize an artwork's information, get member functions, and a PrintInfo() member function. The default constructor should initialize the title to "unknown", the year created to -1. PrintInfo() displays an artist's information by calling the PrintInfo0 function in the Artist class, followed by the artwork's title and the year created. Declare a private field of type Artist in the Artwork classStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started