Allan Didier

Fractions

Goals

Write a Java program the can multiply and divide numbers.

Skills

  • Casting variables
  • Modulus and remainder
  • Output with Strings and numbers

Program Details

Write an application that prompts for and reads the numerator and denominator of a fraction as integers. It should then print the decimal equivalent of the fraction as well as the quotient plus the remainder. Make sure to test with numbers that will generate whole-number and decimal fractions (i.e. 4 /2 = 2.0 and 5 / 2 = 2.5), negative numbers, and zero as the denominator. 

Hints

  • Page 86-87 Conversion Techniques
  • Cast one of the integers as a floating point number.

Resources

Edhesive Term 1

Lesson 6: Casting Variables

Lesson 7: Remainder and Modulus

Lesson 8: Output Strings and Numbers

Lesson 9: Import Math Class

Lesson 10:  Roundoff Error