Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Proper fractions, improper fractions, and mixed fractions are defined at http://

ID: 3901635 • Letter: P

Question

Proper fractions, improper fractions, and mixed fractions are defined at http://www.ltcconline.net/greenl/courses/187/b/impropermixed.htm e. Write a program that prompts the user to enter the numerator and denominator of a fraction number and determines whether it is a proper fraction and improper fraction. For an improper fraction number, display its mixed fraction in the form of a + b / c if b % c is not zero; otherwise, display only the integer. Here are sample runs of the program: Sample 1: Enter a numerator: 16 Enter a denominator: 3 16 /3 is an improper fraction and its mixed fraction is 5 +1/3. Sample 2: Enter a numerator: 6 Enter a denominator: 7 6/7 is a proper fractiorn Sample 3: Enter a numerator: 6 Enter a denominator: 2 6 / 2 is an improper fraction and it can be reduced to 3 Analysis: (Describe the problem including input and output in your own words.)

Explanation / Answer

fraction.html (output to window)

<html>

<head>

</head>

<body>

              <script>

                             var numerator = prompt("Enter a numerator: ");

                             var denominator = prompt("Enter a denominator: ");

                             if(numerator*1 < denominator*1)

                                           document.write(numerator + "/" + denominator + " is a proper fraction");

                             else

                             {

                                           if(numerator%denominator == 0)

                                                          document.write(numerator + "/" + denominator + " is an improper fraction and it can be reduced to " + Math.floor(numerator/denominator));

                                           else

                                                          document.write(numerator + "/" + denominator + " is an improper fraction and its mixed fraction is " + Math.floor(numerator/denominator) + " + " + (numerator%denominator) + "/" + denominator);

                             }

              </script>

</body>

</html>

fraction.html (output as alert)

<html>

<head>

</head>

<body>

              <script>

                             var numerator = prompt("Enter a numerator: ");

                             var denominator = prompt("Enter a denominator: ");

                             if(numerator*1 < denominator*1)

                                           alert(numerator + "/" + denominator + " is a proper fraction");

                             else

                             {

                                           if(numerator%denominator == 0)

                                                          alert(numerator + "/" + denominator + " is an improper fraction and it can be reduced to " + Math.floor(numerator/denominator));

                                           else

                                                          alert(numerator + "/" + denominator + " is an improper fraction and its mixed fraction is " + Math.floor(numerator/denominator) + " + " + (numerator%denominator) + "/" + denominator);

                             }

              </script>

</body>

</html>