4. Write a program that takes input from the user that represents a numerator and denominator...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
4. Write a program that takes input from the user that represents a numerator and denominator of a fraction. Then reduce the fraction to its lowest form and display it to the screen. If appropriate, display the fraction as a mixed number (3 1/2). To reduce a fraction to its lowest terms, divide the numerator and denominator by the greatest common factor. The GCF can be calculated by using Euclid's algorithm. Euclid's algorithm states: Let m represent the numerator and n represent the denominator of a fraction. Divide m by n. Save the divisor in m and save the remainder in n. If n is 0, then stop: m contains the GCF. Otherwise repeat the process. Be sure to display the fraction in a well-formed manner. If the denominator is a one, display the fraction as a whole number. If the denominator is a zero, display a message that the fraction is undefined. A fraction will also never be displayed with a negative denominator. 4. Write a program that takes input from the user that represents a numerator and denominator of a fraction. Then reduce the fraction to its lowest form and display it to the screen. If appropriate, display the fraction as a mixed number (3 1/2). To reduce a fraction to its lowest terms, divide the numerator and denominator by the greatest common factor. The GCF can be calculated by using Euclid's algorithm. Euclid's algorithm states: Let m represent the numerator and n represent the denominator of a fraction. Divide m by n. Save the divisor in m and save the remainder in n. If n is 0, then stop: m contains the GCF. Otherwise repeat the process. Be sure to display the fraction in a well-formed manner. If the denominator is a one, display the fraction as a whole number. If the denominator is a zero, display a message that the fraction is undefined. A fraction will also never be displayed with a negative denominator.
Expert Answer:
Answer rating: 100% (QA)
Python def findgcfa b while b a b b a b return a def reducefractionnumerator denomi... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
What are the SDGs ? What is their history? How do they support global sustainability agenda?
-
Question 5 (a) Assuming you have completed your master's degree programme and employed as a director in one of the public sector institutions in your country. Generally, as a bureaucrat, if you are...
-
Evaluate the stiffness matrix for the elements shown in Figure P11-6. Let E = 100 GPa and v = 0.3? Figure P11-6, (a) (b) (25, 25.0) 2 (10, 0, 0) (40, 0,0) (25, 0, 25) (10, 7, 0) (4, 2, 0) (12, 2, 0)...
-
A heat pump that operates on the ideal vapor compression cycle with refrigerant-134a is used to heat a house. The mass flow rate of the refrigerant is 0.32 kg/s. The condenser and evaporator...
-
Some people are good drivers, and others are bad drivers. The former have a 10% chance of crashing their cars, and the latter have a 30% chance. All have a total wealth of 400, but this will fall to...
-
Tandrin Aviation Holdings Ltd. agreed to sell a jet aircraft to Aero Toy Store, LLC, for \($31.75\) million. ATS paid a \($3\) million deposit to a third party with the balance due upon delivery....
-
Compute FIFO, LIFO, and Average Cost some of the information found on a detail inventory card for Slatkin Inc. for the first month of operations is as follows. (a) From these data compute the ending...
-
Construct and group the following data into classes. Calculate the frequency by classes, relative frequencies and cumulative frequencies. A. Calculate the size of each class (use 6 classes) a....
-
Novelty Inc. developed a new product in 2020 and its financial results follow. To increase acceptance by retailers, Novelty sold the product to retailers with an unconditional right of return, which...
-
Performance and optimization assessment is important to identify performance degradation and bottleneck within a network. Recognizing the element to be measured may help to increase network...
-
What does the auditor do when they identify control exceptions?
-
Name a generally accepted framework used to describe internal controls.
-
Name the four different techniques for testing controls.
-
Why is it important to identify both the strengths and weaknesses in a system of internal controls?
-
Is it true that project managers set the milestones and functional managers hope they can meet them?
-
Varsity Brands, Inc. designs, makes, and sells cheerleading uniforms and has obtained or acquired more than 200 copyright registrations for two-dimensional designs that appear on the surface of their...
-
A Firm intends to invest some capital for a period of 15 years; the Firm's Management considers three Options, each consisting of purchasing a machinery of a specific brand, different for each...
-
Suppose a new process in a system arrives at an average of six processes per minute and each such process requires an average of 8 seconds of service time. Estimate the fraction of time the CPU is...
-
Suppose an internet has the organization shown in Figure, with software using the given transport layer addresses and machines using the given data link layer addresses. a. List the network layer...
-
Given the access matrix in Figure and access control list for each object. D2 D, S2 F1 F2 S3 control S, control seek block read+ Owner write* Owner wakeup OWner seek* control stop Owner owner S2...
-
Refer to the example given in the accounting rate of return (ARR) section of the text (pages 4923), a summary of which is given below. Required: a Calculate the net present value (NPV) of the...
-
What is an accounting management system?
-
What are the types of regulations with which businesses must comply in different jurisdictions?
Study smarter with the SolutionInn App