¤º---------------------------------------------------------------- public class HellowJava { static int var = 100; public static void main(String[] args) { int num1 = 100, num2 = 0; try { System.out.println(num1/num2); } catch(java.lang.ArithmeticException e) { System.out.println("°è»ê¿¡ ¹®Á¦°¡ ÀÖ½À´Ï´Ù"); } } } /* * * int var = 0; System.out.println(var); int sum = addFunction(10,20); System.out.println(sum); * static int addFunction(int num1, int num2) { int hap; hap = num1 + num2 + var; return hap; } * * // TODO Auto-generated method stub * int one[] = new int[3]; for(int i = 0; i= 90) { System.out.println(" ÇÕ°Ý(ÀåÇлý)"); }else if(count >= 60) { System.out.println("ÇÕ°Ý"); }else { System.out.println(" ºÒÇÕ°Ý"); } int jumsu = (count/10)*10; switch(jumsu) { case 100: case 90: System.out.println(" ÇÕ°Ý(ÀåÇлý)"); break; case 80: System.out.println(" 80Á¡ ÇÕ°Ý"); break; case 70: System.out.println(" 70Á¡ ÇÕ°Ý"); break; case 60: System.out.println(" 60Á¡ ÇÕ°Ý"); break; default: System.out.println(" ºÒÇÕ°Ý"); } */ 2. ---------------------------------------------------------------- ---------------------------------------------------------------- public class Car { String color; int speed = 0; static int carCount = 0; final static int MAXSPEED = 200; final static int MINSPEED = 0; static int currentCarCount() { return carCount; } Car(String color, int speed) { this.color = color; this.speed = speed; carCount ++; } Car(int speed){ this.speed = speed; } Car(){ } int getSpeed() { return speed; } void upSpeed(int value) { if(speed + value >= 200) speed = 200; else speed = speed +value; } void downSpeed(int value) { if(speed-value <=0) speed=0; else speed = speed-value; } String getColor() { return color; } } 3. ---------------------------------------------------------------- ---------------------------------------------------------------- ---------------------------------------------------------------- public class exam07 { //public static void main(String[] args) { Automobile auto = new Automobile(); auto.upSpeed(3000); System.out.println("½Â¿ëÂ÷ÀÇ ¼Óµµ´Â" + auto.getSpeed()+"km ÀÔ´Ï´Ù"); } } /* * Car myCar1 = new Car("»¡°­",0); Car myCar2 = new Car("ÆĶû",0); Car myCar3 = new Car("ÃÊ·Ï",0); System.out.println("»ý»êµÈ Â÷ÀÇ ´ë¼ö-->" +Car.carCount); System.out.println("»ý»êµÈ Â÷ÀÇ ´ë¼ö-->" +Car.currentCarCount()); System.out.println("Â÷ÀÇ ÃÖ°í Á¦ÇѼӵµ-->" +Car.MAXSPEED); * * public class exam07 { public static void main(String[] args) { Car myCar1 = new Car("»¡°­",0); Car myCar2 = new Car("ÆĶû",0); Car myCar3 = new Car("ÃÊ·Ï",0); //Car myCar4 = new Car(0); //Car myCar5 = new Car(); Car myCar1 = new Car(); myCar1.color = "»¡°­"; myCar1.speed = 0; Car myCar2 = new Car(); myCar2.color = "ÆĶû"; myCar2.speed = 0; Car myCar3 = new Car(); myCar3.color = "ÃÊ·Ï"; myCar3.speed = 0; myCar1.upSpeed(50); System.out.println("ÀÚµ¿Â÷1ÀÇ »ö»óÀº " + myCar1.getColor() +"À̸ç, ¼Óµµ´Â" + myCar1.getSpeed() + "km ÀÔ´Ï´Ù"); myCar2.upSpeed(20); System.out.println("ÀÚµ¿Â÷2ÀÇ »ö»óÀº" + myCar2.getColor() +"À̸ç, ¼Óµµ´Â" + myCar2.getSpeed() + "km ÀÔ´Ï´Ù"); myCar3.upSpeed(250); System.out.println("ÀÚµ¿Â÷3ÀÇ »ö»óÀº" + myCar3.getColor() +"À̸ç, ¼Óµµ´Â" + myCar3.getSpeed() + "km ÀÔ´Ï´Ù"); myCar4.upSpeed(150); System.out.println("ÀÚµ¿Â÷3ÀÇ »ö»óÀº¾øÀ¸¸ç ¼Óµµ´Â" + myCar4.getSpeed() + "km ÀÔ´Ï´Ù"); } } */ 4. ---------------------------------------------------------------- ---------------------------------------------------------------- ---------------------------------------------------------------- ---------------------------------------------------------------- public class Automobile extends Car { int seatNum; int getseatNum() { return seatNum; } void upSpeed(int value) { if(speed + value >= 300) speed = 300; else speed = speed + (int)value; } }