HW 07 - Practice Variables and Expressions

DUE

Go inside the folder homework, and create a folder 07_practice. Inside this folder, you will write the following programs:

  1. Write a Java program (Fractions.java). In this program you will initialize 4 integers that represent each part of two fractions, namely the numerator and denominator of the first fraction and the numerator and denominator of the second fraction. Your program should add the two fractions and print out the result.

For example, a sample program run might look like this:

  The numerator of the first fraction is 1
  The denominator of the first fraction is 2
  The numerator of the second fraction is 2
  The denominator of the second fraction is 5
  The sum of 1/2 + 2/5 = 9/10
  1. Write a Java program (WorkShift.java). A doctor works 20 hours, 42 minutes, and 16 seconds in one shift at a hospital. Convert the total shift time into seconds and display that information.

NOTE: You must use at least ONE compound operator (+=, -=, *=, /=, %=) to complete this program.