-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLab08.java
23 lines (20 loc) · 1.08 KB
/
Lab08.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Lab07: The GPA Program
// Name:Amir Mousavi
// Oct/26/2013
// Teacher: Christopher Slowley
import javax.swing.JOptionPane;
public class Lab08 {
public static void main (String args[]) {
String strNum1 = JOptionPane.showInputDialog("Enter Numerator 1"); // user types Numerator1
String strDen1 = JOptionPane.showInputDialog("Enter Denominator 1");//user types denominator1
String strNum2 = JOptionPane.showInputDialog("Enter Numerator 2"); // user types Numerator2
String strDen2 = JOptionPane.showInputDialog("Enter Denominator 2");//user types denominator
int num1 = Integer.parseInt(strNum1); // string is converted to int
int den1 = Integer.parseInt(strDen1); // string is converted to int
int num2 = Integer.parseInt(strNum2); // string is converted to int
int den2 = Integer.parseInt(strDen2); // string is converted to int
Rational output= new Rational(num1,den1,num2,den2);
JOptionPane.showMessageDialog(null,output.getRational()); // the message is shown using the Rational.java class
System.exit(0);
}
}