Define a class for a type called fraction

Assignment Help C/C++ Programming
Reference no: EM13166835

 Define a class for a type called Fraction. This class is used to represent a ratio of two

integers. Include mutator functions that allow the user to set the numerator and the

denominator. Also include a member function that returns the value of numerator /

denominator as a double (precision set to 5). Include an additional member function

that outputs the value of the fraction reduced to lowest terms, e.g. instead of

outputting 20/60 the method should output 1/3. This will require finding the greatest

common divisor for the numerator and denominator, and then dividing both by that

number. Embed your class in a test C++ program. Example input/output is shown

below. (25 Points)

Input:

20 60

Output:

0.33333 1/3

4. Write a C++ program that would take two 3x3 matrix and outputs the results of

addition, subtraction, and multiplication. Create a class that can internally store two

3x3 matrices and has three member functions: one that performs addition, one that

performs subtraction, and one that performs multiplication. Use this class in your

program. Example input/output is shown below. (25 Points)

Input:

1 1 1

2 2 2

3 3 3

1 2 3

1 2 3

1 2 3

Output:

2 3 4

3 4 5

4 5 6

0 -1 -2

1 0 -1

2 1 0

3 6 9

6 12 18

9 18 27

 

 

Reference no: EM13166835

Questions Cloud

User can input an odd number in the range from 1 - 25 : this pattern (9 rows), modify your program so that your user can input an odd number in the range from 1 - 25 for the number of rows in the diamond.
Write a program to help the weatherman with weather report : write a program to help the weatherman with his weather report. you will sample the temperature each hour on the hour over the course of 24 hours
What would be the volume of this gas at stp : A sample of neon is collected at 2.7 atm and 12.0 C. it has a volume of 2.25L.What would be the volume of this gas at STP?
What mass of sucrose should be combined : What mass of sucrose should be combined with 521 of water to make a solution with an osmotic pressure of 8.15 at 285 ? (Assume the density of the solution to be equal to the density of the solvent.)
Define a class for a type called fraction : Define a class for a type called Fraction. This class is used to represent a ratio of two integers. Include mutator functions that allow the user to set the numerator and the denominator.
What is the flask volume : What is the flask's volume?
What volume of hi at the same temperature and pressure : At a certain temperature and pressure 2.1 L of H2 reacts with 2.1 L of I2. If all the H2 and I2 are consumed, what volume of HI, at the same temperature and pressure, will be produced?
Explain why acetone in the cyclohexane would invalidate : Explain why acetone in the cyclohexane would invalidate the experiment?
Determine the molarity of the acid : A 100.0 mL of acetic acid solution of unknown molarity is titrated with 0.15 M NaOH solution. The titration requires 43.25 mL of the base. Determine the molarity of the acid, CH3COOH.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Program to declare array alpha of components of type int

Write C++ statements to do the following: Declare an array alpha of 15 components of the type int. Output the value of the tenth component of the array alpha.

  Static field holds rent due date for an office

// static field holds rent due date for an office - // rents are due on the 1st

  Program that can serve as a simple calculator

Write a program that can serve as a simple calculator. This calculator keeps track of a single number (of type double) that is called result and that starts out as 0.0. Each cycle allows the user to repeatedly add, subtract, multiply, or divide by..

  Write a function that takes an integer array

1. Write a function that takes an integer array and the array's size as parameters. The function will check if the array is sorted. If it is, it will return a 1. If it is not sorted it will return 0. The function should not  sort the array.

  Create class has three pieces of information as data members

Create a class called Date in C++ that includes three pieces of information as data members: month (type int), day (type int) and yaer (type int).

  Enter the temperature at noon of each of the five days

Write a program that allows each employee to enter the temperature at noon of each of the five days and displays the highest, lowest, and average (mean) temps.

  Write a method, to be included in a template unsorted list

Write a method, to be included in a template unsorted list class that will print (or reurn) the smallest and the largest values in the list.

  Create class having constructor to recieve two ints

Create a class (in C++)named Card. The class should have two int data members named face and suit.The class should have a constructor that recieves the two ints and uses them to initialize the data members.

  Two-dimensional array of double to hold the sales

Suppose you have a two-dimensional array of double to hold the sales amounts for all your salespeople three years. Assume you employ 50 salespeople and this array already holds valid data.

  Function called timesten that returns back

Write a function called timesTen that returns back to the caller the value passed into the function multiplied by 10. If the value passed into the function is negative, the function also returns the string

  Write a matrix multiplication program

Write a C++, matrix multiplication program which you can instrument to monitor and measure execution time as a function of problem size. Make sure it works in Microsoft Visual Studio.

  Create a structure that has one variable called value

"Create a structure that has one variable called value and one pointer to the list (making it a linked list). Prompt for 5 values from the keyboard as input and store them in the linked list. Print out the current contents of the list.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd