Friday, March 20, 2009

User-Freindly Division

Programmer: Jenelyn Dongiapon
Date Started: March 6,2009
Date Ended: March 20, 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
}
}

No comments:

Post a Comment