Tuesday, March 10, 2009

User-Friendly Division

/*
Programmer: Mary Rose M. Celmar
Date Started: 03-11-09
Date Ended: 03-11-09
*/
import java.util.*;
public class Division{
 public static void main(String [] args){

 Scanner x=new Scanner (System.in);
 String word;
 

  for (int b=0; b<=3; b++){
  int y;
  System.out.print( "Enter Numerator :");
  y=x.nextInt();
  int z;
  System.out.print( "Enter Denaminator :");
  z=x.nextInt();
  int a=y/z;
  System.out.print( "The Answer is :"+a);
  System.out.println();

  if (a==0){
  System.out.print( "You can't divide it by zero "+"Please Try Again");
  
  }else {
  word=x.next();
  char w=word.charAt(0);
   
  System.out.println( "You enter bad data");
  System.out.println( "Please try again");
  System.out.println();
  }
  }
  
 }


No comments:

Post a Comment