728x90

 

 


public class practice_everyday01 {
	public static void main(String[] args) {	
		
		// 전위, 후위 증가연산자 
		// =전치,후치
		int a = 1;
		int b = 2;
		int ab = ++a + b; // (1+1) + 2 = 4 : a=2 b=2 ab=4
		int c = 3;		  //				 c=3
		int ac = a + c--; // 2 + 3 = 5 : a=2 b=2 c=2 
		int bc = ++b - c; // 3 - 1 = 1 : a=2 b=3 c=2
		
		System.out.println(a);
		System.out.println(b);
		System.out.println(c);
		System.out.println(ab);
		System.out.println(ac);
		System.out.println(bc);
		
			
	}
}
728x90
반응형
728x90


728x90
반응형

'small steps > 운동 - 체력이 국력' 카테고리의 다른 글

22.02.15 운동기록  (0) 2022.02.16
22.02.12 운동기록  (0) 2022.02.12
22.02.08 운동기록 & 운동 횟수 조절  (0) 2022.02.08
22.02.06 운동기록  (0) 2022.02.06
22.02.05 운동기록  (0) 2022.02.05
728x90

 

 

public void method1() {
		
	// 실수형으로 국어, 영어, 수학 세 과목의 점수를 입력 받아 총점과 평균을 출력하세요.
	// 이 때 총점과 평균은 정수형으로 처리하세요.
	
		// 실수 입력3칸 총점,평균 정수처리
		Scanner sc = new Scanner(System.in);
		System.out.print("국어 : ");
		float score1 = sc.nextFloat();
		System.out.print("영어 : ");
		float score2 = sc.nextFloat();
		System.out.print("수학 : ");
		double score3 = sc.nextDouble();
		
		// 방법1 : println() + 강제 형변환(int) 
		System.out.println("총점 : "+ (int)(score1+score2+score3)); // (int)
		System.out.println("평균 : "+ (int)((score1+score2+score3)/3));
		
		// 방법2 : printf()
		System.out.printf("총점 : %.0f%n",score1+score2+score3);
		System.out.printf("평균 : %.0f",(score1+score2+score3)/3);
		
	}
728x90
반응형
728x90

 

실수 소수라고 해서 %f를 쓰면 소수점 명령어랑 겹쳐서 안먹히니 %f빼고 %.1f로!!!

 

public void method1() {
	// 키보드로 가로, 세로 값을 실수형으로 입력 받아 사각형의 면적과 둘레를 계산하여 출력하세요
		
		Scanner sc = new Scanner(System.in);
		System.out.print("가로 : ");
		float width = sc.nextFloat();
		System.out.print("세로 : ");
		double length = sc.nextDouble();
		
		// 방법1 : println()
		System.out.println("면적 : " + (width * length));
		System.out.println("둘레 : " + ((width + length)*2));
		
		// 방법2 : printf()
		System.out.printf("면적 : %.2f%n",width*length);
		System.out.printf("둘레 : %.1f" ,(width + length)*2);
		// 실수 소수라고 해서 %f를 쓰면 소수점 명령어랑 겹쳐서 안먹히니 %f빼고 %.1f로
	}
728x90
반응형
728x90


본격적으로 kh수업 들으며 올인 코딩 시작
앞으로 5달정도는 평일2-3회와 주말1-2회로 줄일 계획
헬스장 12시까지 풀리면 더 갈지도 모르겠다


728x90
반응형

'small steps > 운동 - 체력이 국력' 카테고리의 다른 글

22.02.12 운동기록  (0) 2022.02.12
22.02.10 운동기록  (0) 2022.02.10
22.02.06 운동기록  (0) 2022.02.06
22.02.05 운동기록  (0) 2022.02.05
22.01.31 운동기록 & 헬스장 accident  (0) 2022.01.31
728x90

 

 

 

import java.util.Scanner;

public class VariablePractice4 {
	
	public void method1() {
		
	// 영어 문자열 값을 키보드로 입력 받아 문자에서 앞에서 세 개를 출력하세요
	// .charAt()
		
		// 방법1 : println()
		Scanner sc = new Scanner(System.in);
		System.out.print("문자열을 입력하세요 : ");
		String str = sc.nextLine();
		
		System.out.println("첫 번째 문자 : " + str.charAt(0));
		System.out.println("두 번째 문자 : " + str.charAt(1));
		System.out.println("세 번째 문자 : " + str.charAt(2));
		
		// 방법2 : printf()
		char ch1 = str.charAt(0);
		char ch2 = str.charAt(1);
		char ch3 = str.charAt(2);
		System.out.printf("첫 번째 문자 : %c%n",ch1 );
		System.out.printf("두 번째 문자 : %c%n",ch2 );
		System.out.printf("세 번째 문자 : %c",ch3 );
				
	}
}
728x90
반응형
728x90

 

 

 

// 상속 & overriding
class Parents {
	public String doo() {
		return "parents doo";
	}
}
class children extends Parents {
	public String dont() {
		return "children dont";
	}
	//Overriding
	public String doo() {
		System.out.println(super.doo());	// super.
		return "children doo";
	}
}
public class practice_everyday04 {
	public static void main(String[] args) {
		
	Parents one = new Parents();
	one.doo();
	
	children two = new children();
	two.dont();
	two.doo();
//	System.out.println(one);		// 인스턴스one 바로 호출하면 메모리 주소값 출력
									// 객체를 호출하면 디폴트값으로 객체명과 메모리주소를 반환
	System.out.println(one.doo());  // 인스턴스.메소드() 호출해야 return값 반환
	System.out.println(two.dont());
	System.out.println(two.doo());
	}
}
728x90
반응형
728x90


728x90
반응형
728x90


짐 가기가 마음의 부담이다
거울 땜시… 미안한 마음에 소소하게 음료들이링 간식 사가디고 가사 전달


728x90
반응형
728x90

 

dd자바에서 상속 구현은 자식 클래스가 부모 클래스를 참조하여 인스턴스를 통해 구현되기에

상속할려면 인스턴스 사용도 필수

 

return값을 모니터 출력할려면 print()메소드 사용 잊지말고, 시스템 내에서는 잘 return 되고 있는 것도 다시 remind

 

상속 extends 명령어 & 오버라이딩 개념 이해 및 적용 완료

 

 

 

728x90
반응형

+ Recent posts