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

  rewrite that statement in a more readable style.

Give an example statement in C, C++, or Java that is particularly unreadable. Rewrite that statement in a more readable style.

  Prepare a program for a retail-mart company

Prepare a program for a company Retail-Mart.

  Write c program that forks two child processes

Write a C program that forks two child processes. The parent process will print all prime numbers up to 229, the first child process will print the first 50 Fibonacci numbers.

  Variables should be private and the class functions public

All the class variables should be private and the class functions public. The class functions should be implemented in a file Inventory.cpp which should be linked with the inventory.hpp file.

  Write program to input series of hourly temperatures

Create and write a c++ program which inputs series of 24 hourly temperatures from file, and outputs bar chart (using stars) of temperatures for the day.

  Determine order in which constructors of class will execute

Suppose that an object of class three enters its scope, so the constructors of theses classes will execute. Determine the order in which the constructors of these classes will execute.

  Develop a two dimensional interactive game

The player starts as a disk, but can "morph" (that is expand and contract) in selected directions

  What constructors do and when they are executed

Explain what constructors do and when they are executed. Explain the two types of constructors. Provide an example class that includes both types of constructor functions and demonstrate how an object would be instantiated using both types of constru..

  Program that generates 50 random numbers of type

Write a program that generates 50 random numbers of type integer ranges from 1 to 1000 and load all the numbers into a C++ vector. The program should then display the largest, the smallest, the sum, and the average values stored in the vector.

  Which of the following are valid case statements in a switch

What will following segment of code output? int x = 5; if (x != 2)      System,out.println( "This is true!"); else      System.out.println( "This is false!");      System.out.println("This is all folks!");

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Write a very basic doubly-linked list

CptS 122 Lab #2: Linked Lists ,  Along with vectors, linked lists are one of the fundamental data structures in computer science. Unlike vectors, which store information in a contiguous block of computer memory, linked lists have the potential to sto..

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