Question

Please zoom in so the pictures become high resolution. I need three files, FlashDrive.cpp, FlashDrive.h and user_main.cpp. The programming language is C++. I will provide the Sample Test Driver Code as well as the codes given so far in text below.

The purpose of this assignment is to work with exceptions. As you may recall, I have provided you with a sample class named Fvoid eraseData( int amount ); void formatDrive(); // basic accessors and modifiers int getCapacity(); void setCapacity( int a

Sample Testing Driver Code:

cs52::FlashDrive empty;
cs52::FlashDrive drive1(10, 0, false);
cs52::FlashDrive drive2(20, 0, false);

drive1.plugIn();
drive1.formatDrive();
drive1.writeData(5);
drive1.pullOut();

drive2.plugIn();
drive2.formatDrive();
drive2.writeData(2);
drive2.pullOut();

cs52::FlashDrive combined = drive1 + drive2;
// std::cout << "this drive's filled to " << combined.getUsed( ) << std::endl;

cs52::FlashDrive other = combined - drive1;
// std::cout << "the other drives' filled to " << other.getUsed( ) << std::endl;

// let's throw some exceptions...
try
{
  cs52::FlashDrive f(-1, 0, false);
  std::cout << "Negative capacity initialization test failed; no exception thrown" << std::endl;
}
catch (const char* msg)
{
  std::cout << "Negative capacity initialization test failed; C-string thrown" << std::endl;
  std::cout << msg << "\n";
}
catch (std::logic_error e)
{
  std::cout << "Negative capacity initialization test passed; std::logic_error thrown" << std::endl;
  std::cout << e.what() << std::endl;
}
catch (string e)
{
  std::cout << "Negative capacity initialization test failed; string thrown" << std::endl;
  std::cout << e << std::endl;
}
try
{
  cs52::FlashDrive f(10, -1, false);
  std::cout << "Negative used storage initialization test failed; no exception thrown" << std::endl;
}
catch (const char* msg)
{
  std::cout << "Negative used storage initialization test failed; C-string thrown" << std::endl;
  std::cout << msg << "\n";
}
catch (std::logic_error e)
{
  std::cout << "Negative used storage initialization test passed; std::logic_error thrown" << std::endl;
  std::cout << e.what() << std::endl;
}
catch (string e)
{
  std::cout << "Negative used storage initialization test failed; string thrown" << std::endl;
  std::cout << e << std::endl;
}

try
{
  cs52::FlashDrive f(1, 10, false);
  std::cout << "Capacity < Used storage initialization test failed; no exception thrown" << std::endl;
}
catch (const char* msg)
{
  std::cout << "Capacity < Used storage initialization test failed; C-string thrown" << std::endl;
  std::cout << msg << "\n";
}
catch (std::logic_error e)
{
  std::cout << "Capacity < Used storage initialization test passed; std::logic_error thrown" << std::endl;
  std::cout << e.what() << std::endl;
}
catch (string e)
{
  std::cout << "Capacity < Used storage initialization test failed; string thrown" << std::endl;
  std::cout << e << std::endl;
}

try
{
  drive2.writeData(10000);
  std::cout << "Writing beyond capacity test failed" << std::endl;
}
catch (const char* msg)
{
  std::cout << "Writing beyond capacity test failed; C-string thrown" << std::endl;
  std::cout << msg << "\n";
}
catch (std::logic_error e)
{
  std::cout << "Writing beyond capacity test passed; std::logic_error thrown" << std::endl;
  std::cout << e.what() << std::endl;
}
catch (string e)
{
  std::cout << "Writing beyond capacity test failed; string thrown" << std::endl;
  std::cout << e << std::endl;
}

try
{
  empty = empty - combined;
  std::cout << "Subtracting more data than capacity allows test failed" << std::endl;
}
catch (const char* msg)
{
  std::cout << "Subtracting more data than capacity allows test failed; C-string thrown" << std::endl;
  std::cout << msg << "\n";
}
catch (std::logic_error e)
{
  std::cout << "Subtracting more data than capacity allows test passed; std::logic_error thrown" << std::endl;
  std::cout << e.what() << std::endl;
}
catch (string e)
{
  std::cout << "Subtracting more data than capacity allows test failed; string thrown" << std::endl;
  std::cout << e << std::endl;
}

// read in a FlashDrive...
// the class designer for FlashDrive (that's you!)
// gets to decide which fields matter and should be read in
std::stringstream ss;
ss.str("6 4");
cs52::FlashDrive sample;
ss >> sample;
if (sample.getCapacity() == 6)
{
  std::cout << "instream operator capacity set correctly" << std::endl;
}
else
{
  std::cout << "instream operator capacity set incorrectly" << std::endl;
}
if (sample.getUsed() == 4)
{
  std::cout << "instream operator storage used set correctly" << std::endl;
}
else
{
  std::cout << "instream operator storage used set incorrectly" << std::endl;
}

// print out a FlashDrive...
// the class designer for FlashDrive (that's you!)
// gets to decide which fields matter and should be printed
std::cout << sample << std::endl;

FlashDrive.cpp:

#include
#include
#include "FlashDrive.h"
using namespace std;

namespace cs52
{
FlashDrive::FlashDrive()
{
my_StorageCapacity = 0;
my_StorageUsed = 0;
my_IsPluggedIn = false;
}
  
FlashDrive::FlashDrive(int capacity, int used, bool pluggedIn)
{
my_StorageCapacity = capacity;
my_StorageUsed = used;
my_IsPluggedIn = pluggedIn;
}
  
void FlashDrive::plugIn()
{
my_IsPluggedIn = true;
}
  
void FlashDrive::pullOut()
{
my_IsPluggedIn = false;
}
  
void FlashDrive::writeData(int amount)
{
my_StorageUsed += amount;
}
  
void FlashDrive::eraseData(int amount)
{
my_StorageUsed -= amount;
}
  
void FlashDrive::formatDrive()
{
my_StorageUsed = 0;
}
  
int FlashDrive::getCapacity()
{
return (my_StorageCapacity);
}
  
void FlashDrive::setCapacity(int amount)
{
my_StorageCapacity = amount;
}
  
int FlashDrive::getUsed()
{
return (my_StorageUsed);
}
  
void FlashDrive::setUsed(int amount)
{
my_StorageUsed = amount;
}
  
bool FlashDrive::isPluggedIn()
{
return (my_IsPluggedIn);
}
  
FlashDrive operator+(const FlashDrive& f1, const FlashDrive& f2)
{
FlashDrive f3;
  
f3.my_StorageUsed = f1.my_StorageUsed + f2.my_StorageUsed;
  
if (f1.my_StorageCapacity > f2.my_StorageCapacity)
{
f3.my_StorageCapacity = f1.my_StorageCapacity;
}
else
{
f3.my_StorageCapacity = f2.my_StorageCapacity;
}
  
return f3;
}
  
bool operator<(const FlashDrive& f1, const FlashDrive& f2)
{
bool storageUsed = false;
if (f1.my_StorageUsed < f2.my_StorageUsed)
{
storageUsed = true;
}
return storageUsed;
}
  
bool operator>(const FlashDrive& f1, const FlashDrive& f2)
{
bool storageUsed = false;
if (f1.my_StorageUsed > f2.my_StorageUsed)
{
storageUsed = true;
}
return storageUsed;
}
  
FlashDrive operator-(const FlashDrive& f1, const FlashDrive& f2)
{
int error;
FlashDrive f3;
  
if (f1.my_StorageCapacity > f2.my_StorageCapacity)
{
f3.my_StorageCapacity = f1.my_StorageCapacity;
}
else
{
f3.my_StorageCapacity = f2.my_StorageCapacity;
}
  
f3.my_StorageUsed = f1.my_StorageUsed - f2.my_StorageUsed;
  
return f3;
}
  
ostream& operator<<(ostream& out, const FlashDrive& f1)
{
return out;
}
  
std::istream& operator>>(std::istream& in, FlashDrive& f1)
{
return in;
}

} // namespace cs52

FlashDrive.h:

#ifndef FLASHDRIVE_H
#define FLASHDRIVE_H
#include

namespace cs52 {
class FlashDrive
{
public:
FlashDrive();
FlashDrive(int capacity, int used, bool pluggedIn);
  
void plugIn();
void pullOut();
void writeData(int amount);
void eraseData(int amount);
void formatDrive();
  
int getCapacity();
void setCapacity(int amount);
int getUsed();
void setUsed(int amount);
bool isPluggedIn();
  
friend FlashDrive operator+(const FlashDrive& f1, const FlashDrive& f2);
friend bool operator<(const FlashDrive& f1, const FlashDrive& f2);
friend bool operator>(const FlashDrive& f1, const FlashDrive& f2);
friend FlashDrive operator-(const FlashDrive& f1, const FlashDrive& f2);
friend std::ostream& operator<<(std::ostream& out, const FlashDrive& f1);
friend std::istream& operator>>(std::istream& in, FlashDrive& f1);
  
private:
int my_StorageCapacity; // in kilobytes
int my_StorageUsed; // in kilobytes
bool my_IsPluggedIn; // am I attached to a computer?
};
}

#endif

user_main.cpp:

/* Main function of the C++ program. */

#include

using namespace std;

/*
* This is your main function - my hidden main() will execute this function
* when you "Run", but execute the tests when you hit "Submit"
*/
int user_main() {
// YOUR IMPLEMENTATION GOES HERE
return 0;
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

// FlashDrive.h
#ifndef FLASHDRIVE_H
#define FLASHDRIVE_H

#include <iostream>

namespace cs52{

class FlashDrive{
public:
// constructors
FlashDrive();
FlashDrive(int capacity, int used, bool pluggedIn);

void plugIn();
void pullOut();
void writeData(int amount);
void eraseData(int amount);
void formatDrive();

// basic accessors and modifiers
int getCapacity();
void setCapacity(int amount);
int getUsed();
void setUsed(int amount);
bool isPluggedIn();

// overloaded +, -, >, <, >>, <<
friend FlashDrive operator+(const FlashDrive& f1, const FlashDrive& f2);
friend FlashDrive operator-(const FlashDrive& f1, const FlashDrive& f2);
friend bool operator>(const FlashDrive& f1, const FlashDrive& f2);
friend bool operator<(const FlashDrive& f1, const FlashDrive& f2);
friend std::ostream &operator<<( std::ostream &stream, const FlashDrive &f1 );
friend std::istream &operator>>( std::istream &stream, FlashDrive &f1 );

private:

int my_StorageCapacity; // in kilobytes
int my_StorageUsed; // in kilobytes
bool my_IsPluggedIn; // am I attached to a computer?

};
}

#endif

//end of FlashDrive.h

// FlashDrive.cpp
#include "flashdrive.h"
#include <stdexcept>
using namespace std;

namespace cs52{

// default constructor to initialize capacity, used to 0 and pluggedIn to false
FlashDrive::FlashDrive()
{
       my_StorageCapacity = 0;
       my_StorageUsed = 0;
       my_IsPluggedIn = false;
   }

// parameterized constructor to initialize capacity, used and pluggedIn to passed values if valid
FlashDrive::FlashDrive(int capacity, int used, bool pluggedIn)
{
       my_IsPluggedIn = pluggedIn;
// check that capacity or used is not negative, if it is throw exception
if(capacity < 0 || used < 0)
{
throw logic_error("negative initialization of capacity and/or used");
}

// if capacity < used, throw exception
if(capacity < used)
throw logic_error("Capacity of Flashdrive must be greater or equal to used");

// if all valid, set the capacity and used
my_StorageCapacity = capacity;
my_StorageUsed = used;

}

// set pluggedIn to true
void FlashDrive::plugIn()
{
my_IsPluggedIn = true;
}

// set pluggedIn to false
void FlashDrive:: pullOut()
{
my_IsPluggedIn = false;
}

// function to write amount of data to FlashDrive
void FlashDrive:: writeData(int amount)
{
// validate amount is not negative and neither adding this amount of data will make used > capacity
// if invalid, throw exception
if((amount < 0) || ((my_StorageUsed+amount) > my_StorageCapacity))
throw logic_error("Invalid amount to write to Flashdrive");
my_StorageUsed += amount; // if valid, add amount to used
}

// function to erase amount of data from FlashDrive
void FlashDrive::eraseData(int amount)
{
// validate amount is not negative and neither amount > used data in flashdrive
// if invalid, throw exception
if((amount < 0) || (amount > my_StorageUsed))
throw logic_error("Invalid amount to erase from Flashdrive");
my_StorageUsed -= amount; // if valid, subtract amount from used
}

// function to format the drive i.e set used to 0
void FlashDrive:: formatDrive()
{
my_StorageUsed = 0;
}

// function to return capacity
int FlashDrive:: getCapacity()
{
return my_StorageCapacity;
}

// function to set capacity
void FlashDrive:: setCapacity(int amount)
{
// validate capacity to set is not negative and neither it is greater than the data used in the flashdrive
// if invalid, throw exception
if(amount < 0 || amount < my_StorageUsed)
throw logic_error("Invalid capacity initialization");
my_StorageCapacity = amount; // if valid, update capacity
}

// function to return used storage
int FlashDrive::getUsed()
{
return my_StorageUsed;
}

// function to set used storage
void FlashDrive:: setUsed(int amount)
{
// validate used to set is not negative and neither it is greater than the capacity used in the flashdrive
// if invalid, throw exception
if(amount < 0 || amount > my_StorageCapacity)
throw logic_error("Invalid used initialization");
my_StorageUsed = amount; // if valid, update used
}

// function to return if the flashdrive is plugged or not
bool FlashDrive:: isPluggedIn()
{
return(my_IsPluggedIn == true);
}

// function to add used and set capacity as larger of the two to return a new FlashDrive
FlashDrive operator+(const FlashDrive& f1, const FlashDrive& f2)
{

FlashDrive f3;
f3.my_StorageUsed = f1.my_StorageUsed + f2.my_StorageUsed;
if (f1.my_StorageCapacity > f2.my_StorageCapacity)
{
f3.my_StorageCapacity = f1.my_StorageCapacity;
}
else
{
f3.my_StorageCapacity = f2.my_StorageCapacity;
}

return f3;
}

// function to subtract used of f2 to from f1 and set capacity to be the greater of the two
// will throw exception if f1's used is less than f2's used
FlashDrive operator-(const FlashDrive& f1, const FlashDrive& f2)
{
if(f1.my_StorageUsed < f2.my_StorageUsed)
throw logic_error("Storage used on first flashdrive must be greater than or equal to storage used in second flashdrive");

FlashDrive f3;
if (f1.my_StorageCapacity > f2.my_StorageCapacity)
{
f3.my_StorageCapacity = f1.my_StorageCapacity;
}
else
{
f3.my_StorageCapacity = f2.my_StorageCapacity;
}

return f3;
}


// function that returns true if used of f1 > used of f2. else false
bool operator>(const FlashDrive& f1, const FlashDrive& f2)
{
return f1.my_StorageUsed > f2.my_StorageUsed;
}

// function that returns true if used of f1 < used of f2, else false
bool operator<(const FlashDrive& f1, const FlashDrive& f2)
{
return f1.my_StorageUsed < f2.my_StorageUsed;
}

// function to output capacity and used to output stream
ostream &operator<<( ostream &stream, const FlashDrive &f1 )
{
stream << "Capacity: "<<f1.my_StorageCapacity<<", storage used: "<<f1.my_StorageUsed;
return stream;
}

// function to read capacity and used from input stream
istream &operator>>( istream &stream, FlashDrive &f1 )
{
stream>>f1.my_StorageCapacity>>f1.my_StorageUsed;
return stream;
}

}
//end of FlashDrive.cpp

// user_main.cpp : C++ driver program to test FlashDrive class
#include <iostream>
#include "flashdrive.h"
#include <stdexcept>
#include <sstream>

using namespace std;


int main()
{
cs52::FlashDrive empty;
cs52::FlashDrive drive1(10, 0, false);
cs52::FlashDrive drive2(20, 0, false);

drive1.plugIn();
drive1.formatDrive();
drive1.writeData(5);
drive1.pullOut();

drive2.plugIn();
drive2.formatDrive();
drive2.writeData(2);
drive2.pullOut();

cs52::FlashDrive combined = drive1 + drive2;
// std::cout << "this drive's filled to " << combined.getUsed( ) << std::endl;

cs52::FlashDrive other = combined - drive1;
// std::cout << "the other drives' filled to " << other.getUsed( ) << std::endl;

// let's throw some exceptions...
try
{
cs52::FlashDrive f(-1, 0, false);
std::cout << "Negative capacity initialization test failed; no exception thrown" << std::endl;
}
catch (const char* msg)
{
std::cout << "Negative capacity initialization test failed; C-string thrown" << std::endl;
std::cout << msg << "\n";
}
catch (std::logic_error e)
{
std::cout << "Negative capacity initialization test passed; std::logic_error thrown" << std::endl;
std::cout << e.what() << std::endl;
}
catch (string e)
{
std::cout << "Negative capacity initialization test failed; string thrown" << std::endl;
std::cout << e << std::endl;
}

try
{
cs52::FlashDrive f(10, -1, false);
std::cout << "Negative used storage initialization test failed; no exception thrown" << std::endl;
}
catch (const char* msg)
{
std::cout << "Negative used storage initialization test failed; C-string thrown" << std::endl;
std::cout << msg << "\n";
}
catch (std::logic_error e)
{
std::cout << "Negative used storage initialization test passed; std::logic_error thrown" << std::endl;
std::cout << e.what() << std::endl;
}
catch (string e)
{
std::cout << "Negative used storage initialization test failed; string thrown" << std::endl;
std::cout << e << std::endl;
}

try
{
cs52::FlashDrive f(1, 10, false);
std::cout << "Capacity < Used storage initialization test failed; no exception thrown" << std::endl;
}
catch (const char* msg)
{
std::cout << "Capacity < Used storage initialization test failed; C-string thrown" << std::endl;
std::cout << msg << "\n";
}
catch (std::logic_error e)
{
std::cout << "Capacity < Used storage initialization test passed; std::logic_error thrown" << std::endl;
std::cout << e.what() << std::endl;
}
catch (string e)
{
std::cout << "Capacity < Used storage initialization test failed; string thrown" << std::endl;
std::cout << e << std::endl;
}

try
{
drive2.writeData(10000);
std::cout << "Writing beyond capacity test failed" << std::endl;
}
catch (const char* msg)
{
std::cout << "Writing beyond capacity test failed; C-string thrown" << std::endl;
std::cout << msg << "\n";
}
catch (std::logic_error e)
{
std::cout << "Writing beyond capacity test passed; std::logic_error thrown" << std::endl;
std::cout << e.what() << std::endl;
}
catch (string e)
{
std::cout << "Writing beyond capacity test failed; string thrown" << std::endl;
std::cout << e << std::endl;
}

try
{
empty = empty - combined;
std::cout << "Subtracting more data than capacity allows test failed" << std::endl;
}
catch (const char* msg)
{
std::cout << "Subtracting more data than capacity allows test failed; C-string thrown" << std::endl;
std::cout << msg << "\n";
}
catch (std::logic_error e)
{
std::cout << "Subtracting more data than capacity allows test passed; std::logic_error thrown" << std::endl;
std::cout << e.what() << std::endl;
}
catch (string e)
{
std::cout << "Subtracting more data than capacity allows test failed; string thrown" << std::endl;
std::cout << e << std::endl;
}

// read in a FlashDrive...
// the class designer for FlashDrive (that's you!)
// gets to decide which fields matter and should be read in
std::stringstream ss;
ss.str("6 4");
cs52::FlashDrive sample;
ss >> sample;
if (sample.getCapacity() == 6)
{
std::cout << "instream operator capacity set correctly" << std::endl;
}
else
{
std::cout << "instream operator capacity set incorrectly" << std::endl;
}
if (sample.getUsed() == 4)
{
std::cout << "instream operator storage used set correctly" << std::endl;
}
else
{
std::cout << "instream operator storage used set incorrectly" << std::endl;
}

// print out a FlashDrive...
// the class designer for FlashDrive (that's you!)
// gets to decide which fields matter and should be printed
std::cout << sample << std::endl;
return 0;
}

//end of user_main.cpp

Output:

Negative capacity initialization test passed; std::logic_error thrown negative initialization of capacity and/or used Negativ

Add a comment
Know the answer?
Add Answer to:
Please zoom in so the pictures become high resolution. I need three files, FlashDrive.cpp, FlashDrive.h and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Background: This assignment deals with inheritance. Inheritance is one of the major principles of object-oriented programming....

    Background: This assignment deals with inheritance. Inheritance is one of the major principles of object-oriented programming. In C++, one of the biggest goals is "code reuse". Inheritance accomplishes this. In order to get inheritance working in C++, you must get both the structure of your .h files as well as the implementation of your constructor correct. Constructor implementations must use an initialization list. Please review the book and the online content on these issues so you know how it works...

  • Background: The purpose of this assignment is to practice dealing with exception handling and textual data....

    Background: The purpose of this assignment is to practice dealing with exception handling and textual data. Exception handling is a very important part of being an object-oriented programming. Rather returning some kind of int return value every time you tickle an object, C++ programmers expect methods to focus on their task at hand. If something bad happens, C++ programmers expect methods to throw exceptions. When caught, exceptions can be processed. When uncaught, they cause a program to terminate dead in...

  • I have provided you with a sample class named FlashDrive which has been diagrammed below. Using...

    I have provided you with a sample class named FlashDrive which has been diagrammed below. Using the FlashDrive class provided earlier, upgrade the class so that it supports various operators. Make operator+ combine together the contents of two FlashDrive, as long as the contents does not exceed the size. Make operator- subtract one FlashDrive contents from another, as long as the size or contents don't go negative. Support the >> and << operators to allow instances to be read from...

  • Help please with a Project in C++ In C++, many of the keyboard symbols that are used between two ...

    Help please with a Project in C++ In C++, many of the keyboard symbols that are used between two variables can be given a new meaning. This feature is called operator overloading and it is one of the most popular C++ features. Any class can choose to provide a new meaning to a keyboard symbol. Not every keyboard letter is re-definable in this way, but many of the ones we have encountered so far are like +, -, *, /,...

  • Project 1 - Operator Overloading (FlashDrive 2.0) In C++, many of the keyboard symbols that are...

    Project 1 - Operator Overloading (FlashDrive 2.0) In C++, many of the keyboard symbols that are used between two variables can be given a new meaning. This feature is called operator overloading and it is one of the most popular C++ features. Any class can choose to provide a new meaning to a keyboard symbol. Not every keyboard letter is re-definable in this way, but many of the ones we have encountered so far are like +, -, *, /,...

  • In this assignment you are required to complete a class for fractions. It stores the numerator...

    In this assignment you are required to complete a class for fractions. It stores the numerator and the denominator, with the lowest terms. It is able to communicate with iostreams by the operator << and >>. For more details, read the header file. //fraction.h #ifndef FRACTION_H #define FRACTION_H #include <iostream> class fraction { private: int _numerator, _denominator; int gcd(const int &, const int &) const; // If you don't need this method, just ignore it. void simp(); // To get...

  • Project 2 - Flashdrive 1.0 I have provided you with a sample class named FlashDrive which...

    Project 2 - Flashdrive 1.0 I have provided you with a sample class named FlashDrive which has been diagrammed below and described in the online course content. For this unit, I'd like you to identify additional member variables (data) that would be appropriate for the class FlashDrive. I would also like you to identify additional methods (functions) that would be appropriate for the class FlashDrive. Submit a .h file for FlashDrive with the new possible methods and members you have...

  • A library maintains a collection of books. Books can be added to and deleted from and...

    A library maintains a collection of books. Books can be added to and deleted from and checked out and checked in to this collection. Title and author name identify a book. Each book object maintains a count of the number of copies available and the number of copies checked out. The number of copies must always be greater than or equal to zero. If the number of copies for a book goes to zero, it must be deleted from the...

  • C++ CODE /* This is program project 2 on page 695. * Before you begin the...

    C++ CODE /* This is program project 2 on page 695. * Before you begin the project, please read the project description * on page 695 first. * * Author: Your Name * Version: Dates */ #include <iostream> #include <cmath> #include <cassert> using namespace std; class Fraction { public: // constructor Fraction(int a, int b); // generate a fraction which is a/b Fraction(int a); // generate a fraction which is a/1 Fraction(); // generate a fraction which is 0/1. i.e...

  • NEED ASAP PLEASE HELP Task: --------------------------------------------------------------------------------------...

    NEED ASAP PLEASE HELP Task: --------------------------------------------------------------------------------------------------------------------------------- Tasks to complete: ---------------------------------------------------------------------------------------------------------------------------------------- given code: ----------------------------------------------------------------------------------------------------------------------------------------------- main.cpp #include <iostream> #include <iomanip> #include "fractionType.h" using namespace std; int main() { fractionType num1(5, 6); fractionType num2; fractionType num3; cout << fixed; cout << showpoint; cout << setprecision(2); cout << "Num1 = " << num1 << endl; cout << "Num2 = " << num2 << endl; cout << "Enter the fraction in the form a / b: "; cin >> num2; cout << endl; cout <<...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT