Question: Using C++ Part A Implement a program that prompts once for two positive integers i1 and i2 and displays whether i1 and i2 are amicable.

Using C++

Part A

Implement a program that prompts once for two positive integers i1 and i2 and displays whether i1 and i2 are amicable. Let sdi1 be the sum of the divisors of i1, including 1 but excluding i1. Let sdi2 be the sum of the divisors of i2 including 1 but excluding i2 The numbers i1 and i2 are amicable if sdi1 equals i2 as well as sdi2 equals i1

Enter two positive integers: 220 284 The sum of the divisors of 220 is 284 The sum of the divisors of 284 is 220 Hence 220 and 284 are amicable numbers
Enter two positive integers: 1234 1678 The sum of the divisors of 1234 is 620 The sum of the divisors of 1678 is 842 Hence 1234 and 1678 are not amicable numbers

Part B

Implement a program that determines the machine epsilon for float and double types. Machine epsilon is defined as the difference between a floating-point number, X, and the next number that can be represented, x+ epsilon, An approximation can be computed by initializing epsilon at 1.0 and keep multiplying it by a Gama<1.0 until ( X+Gamaepsilon==X).

Your program should prompt for two floating-point numbers, one for X and one for Gama, and display machine epsilons for float and double types. For example:

Enter a floating-point number: 5.0 Enter a floating-point number less than 1.0: 0.5 The machine epsilon for float type is 4.76837e-07 The machine epsilon for double type is 8.88178e-16

Enter a floating-point number: 1.0 Enter a floating-point number less than 1.0: 0.9 The machine epsilon for float type is 6.54745e-08 The machine epsilon for double type is 1.19232e-16

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!