User-Friendly Division by: Albert Ampo
/*
Programmer: Albert Ampo
Date Started: March 6,2009
Date Ended: March 7, 2009
*/
import javax.swing.*;
public class UserFriendlyDivision{
public staic void main(String args[]){
char ans='y';
while(ans=='y'){
double x=Integer.parseInt(JOptionPane.showInputDialog("Enter numerator:"));//ask user input
double y=Integer.parseInt(JOptionPane.showInputDialog("Enter divisor:"));//ask user second input
double answer=x/y; //formula to get the answer
System.out.println(+ x + " / " + ); //display the input ask
System.out.println("The quotient is:"+answer); //display the answer
if(y==0)//conditional method
{
System.out.println("You cannot divide the " + x + " to 0. ");// display th econditional staement
}
String a=(JOptionPane.showInputDialog("Do you want to continue?");//ask user to continue the program
ans=a.chartAt(0);//get the input
}
}//end main method
}//end class UserFriendlyDivision
Friday, March 6, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment