Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Assignment on Classes: Define a class, fruitType, to store the following data about a fruit: Fruitname (string), color (string), fat (int), sugar (int), and

C++ Assignment on Classes:

Define a class, fruitType, to store the following data about a fruit:

Fruitname (string), color (string), fat (int), sugar (int), and carbohydrate (int). Implement your class with accessor and mutator, display method to display the output.

Write a test program that

Reads a data file of 5 different fruits

Writes output on monitor and an output file.

Compare any two fruits by fat, sugar, & carbohydrate, and display the healthier one

Here is a sample data file:

Jackfruit green 5 120 50

Strawberry red 7 89 30

Mango yellow 15 150 110

Apple green 6 30 100

Grape purple 5 50 40

Please write the code using separate files for classes as the example below shows:

image text in transcribed

Storeltem.h #ifndef STOREITEM_H #define STOREITEM_H Storeltem.cpp #include using namespace std; #include "StoreItem.h" class StoreItem { public: void SetWeightOunces (int ounces); void Print() const; private: int weightOunces; void StoreItem:: SetWeightOunces (int ounces) { weightOunces = ounces; void StoreItem:: Print() const { cout using namespace std; #include "StoreItem.h" int main() { StoreItem item1; Compilation example fg++ -Wall StoreItem.cpp main.cpp a.out Weight (ounces): 16 item1. SetWeightOunces (16); item1. Print(); return 0; Storeltem.h #ifndef STOREITEM_H #define STOREITEM_H Storeltem.cpp #include using namespace std; #include "StoreItem.h" class StoreItem { public: void SetWeightOunces (int ounces); void Print() const; private: int weightOunces; void StoreItem:: SetWeightOunces (int ounces) { weightOunces = ounces; void StoreItem:: Print() const { cout using namespace std; #include "StoreItem.h" int main() { StoreItem item1; Compilation example fg++ -Wall StoreItem.cpp main.cpp a.out Weight (ounces): 16 item1. SetWeightOunces (16); item1. Print(); return 0

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

Students also viewed these Databases questions

Question

Example. Evaluate 5n+7 lim 7-00 3n-5

Answered: 1 week ago

Question

Organize and support your main points

Answered: 1 week ago

Question

Move smoothly from point to point

Answered: 1 week ago

Question

Outlining Your Speech?

Answered: 1 week ago