Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This week we'll write a C# program that acts as a calculator for Fraction values. The calculator will act similarly to our previous int calculator.

This week we'll write a C# program that acts as a calculator for Fraction values. The calculator will act similarly to our previous int calculator. A menu is presented to the user allowing the user to select add, subtract, multiply, divide, or exit operations. The user is prompted to enter 2 fraction values. The program then performs the requested operation on the 2 fraction values and displays the result. The program continues presenting the menu and performing arithmetic operations until the user selects exit. The program should prevent division by 0. There are also internal requirements: You must create and use a class Fraction to handle fraction operations. Class Fraction must be in a separate source file. When you zip the project folder, both C# source files will automatically be included! Fraction should provide, at least, the following public methods: Display Enter Add Subtract Multiply Divide You must actually use these methods in your program. These methods should do what they say, and nothing else. For example, the Add method should add two Fractions together and return the result. The Add methods should NOT prompt the user to enter Fractions, or display the result. Fraction attributes must be private. Fraction methods should guard against invalid Fraction object states (e.g. 0 denominators). Thoughts: You already have a class Fraction and a calculator program from previous assignments. Feel free to "steal" code from them heavily. You may find it useful to overload many of Fraction's methods, particularly the constructor. It's your choice whether to use static or non-static methods. It's OK to use both. There are future lesson considerations that may make the static versions of arithmetic methods slightly more desirable than the non-static versions. For example "public static Fraction Add(Fraction leftFrac, Fraction rightFrac)" Guarding against division by 0 means that the 2nd Fraction's numerator can't be 0. In case you have forgotten... a/b + c/d = (ad + bc)/bd a/b - c/d = (ad - bc)/bd a/b * c/d = ac/bd a/b c/d = ad/bc

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

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

7. Where Do We Begin?

Answered: 1 week ago

Question

a. What is the purpose of the team?

Answered: 1 week ago

Question

b. What are its goals and objectives?

Answered: 1 week ago