티스토리 뷰
반응형
package prj190702;
import java.util.*;
public class Doublefor_1 {
========================*찍는 피라미드 함수
public static void Pyramid(int a) {
for(int i=0; i<a; i++) {
for(int j=0; j<=i; j++) {
System.out.print("*");
}
System.out.println();
}
}
/////함수 오버로딩
// 인자 두개 받아서 p값만큼 별 갯수 증가시킴 즉 a에 10, p에 2면 1>3>5>7 식으로 별 찍힘
public static void Pyramid(int a, int p) {
for(int i=0; i<a; i+=p) {
for(int j=0; j<=i; j++) {
System.out.print("*");
}
System.out.println();
}
}
===================2차원 배열====================
public static void main(String[] args) {
int [] [] sdim = new int [5][3];
for(int i =0; i<sdim.length; i++) {//열
System.out.println("외부"+sdim.length);
for(int j =0; j<sdim[i].length; j++) {//행
sdim[i][j] = 10;
System.out.print(sdim[i].length);
}
System.out.println("===========================");
}
//===========================2차원 배열==========================
for(int i =0; i<sdim.length; i++) {
for(int j =0; j<sdim[i].length; j++) {
sdim[i][j] = (i+1)*5;
}
}
for(int i =0; i<sdim.length; i++) {
for(int j =0; j<sdim[i].length; j++) {
System.out.print(sdim[i][j]+" ");
}
System.out.println();
}
========================함수이용한 *찍기=============================
System.out.print("별 피라미드 몇 열? :");
Scanner scan = new Scanner(System.in);
int hang = scan.nextInt();
System.out.print("별 증가 수? :");
int yeol = scan.nextInt();
Pyramid(hang, yeol);
System.out.println("========================================");
Pyramid(hang);
===========================함수이용=================================
System.out.print("메뉴 입력: ");
Scanner scan = new Scanner(System.in);
char menu = scan.next().charAt(0);
switch(menu) {
case 'a' :
System.out.print("단수 입력: ");
int dan = scan.nextInt();
Gugudan(dan);
break;
case 'b' :
System.out.print("숫자 입력: ");
int Soo = scan.nextInt();
Sum(Soo);
break;
}
}
public static void Gugudan(int a) {
for(int j =1; j<=9; j++) System.out.printf("%d * %d = %d\n", a, j,a*j);
}
public static void Sum(int a) {
int sum = a *30;
System.out.println(sum);
}
}
반응형
'JAVA' 카테고리의 다른 글
190703 클래스 생성자 오버로딩 (0) | 2019.07.03 |
---|---|
190703 class 연습 (0) | 2019.07.03 |
190702 배열, 함수 이용한 성적관리 (0) | 2019.07.02 |
190702 클래스, 생성자 오버로딩 (0) | 2019.07.02 |
190701 성적관리프로그램(배열) (0) | 2019.07.01 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 이메일 정규식
- poi 엑셀
- select제어
- 정규식 특수문자
- PageNotFound - No mapping for GET
- JSON파싱
- 공백찾기
- poi
- IntelliJ #gradle #tomcat #spring #springmvc
- 정규식 한글만
- ''찾기
- 정규식
- js
- no getter for property named
- 인텔리제이
- mybatis
- 계좌번호정규식
- JSON날짜
- selectbox
- 정규식 숫자만
- Regex
- Failed to load resource: the server responded with a status of 404 (Not Found)
- spring 엑셀
- POI EXCEL
- 엑셀다운로드
- SpringXmlModelInspection
- spring error #
- JSON
- Spring
- jQuery
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함