BooleanExamples

From ggc

Jump to: navigation, search

01 /**
02  * All about my application here.
03  @author Jam Jenkins
04  */
05 public class BooleanExamples
06 {
07   /**determine if a number is big or not.  A number
08    * is considered big is it is more than 50, otherwise
09    * it is considered small.  Return true from this
10    * method if the number is considered big, false
11    if it is not considered big.*/
12   public static boolean isBig(double number)
13   {
14     if(number>=50)
15       return true;
16     else
17       return false;
18   }
19 
20   public static boolean isSameAndBig(int x, int y)
21   {
22     if(x>50 && y>50 && x==y)
23       return true;
24     else
25       return false;
26   }
27 
28   public static boolean isValidGrade(int grade)
29   {
30     if(0>grade && grade>100)
31       return false;
32     else
33       return true;
34   }
35 
36   public static void main(String[] args)
37   {
38     if(isValidGrade(7)==true)
39       System.out.println("Passed isValidGrade(7)");
40     else
41       System.out.println("Failed isValidGrade(7)");
42     if(isValidGrade(-7)==false)
43       System.out.println("Passed isValidGrade(-7)");
44     else
45       System.out.println("Failed isValidGrade(-7)");
46     if(isValidGrade(700)==false)
47       System.out.println("Passed isValidGrade(700)");
48     else
49       System.out.println("Failed isValidGrade(700)");
50     if(isValidGrade(0)==true)
51       System.out.println("Passed isValidGrade(0)");
52     else
53       System.out.println("Failed isValidGrade(0)");
54   }
55 }


Download/View BooleanExamples.java





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter