import java.io.IOException;

public class InputStreamEx {
 public static void main(String[] args) throws IOException {
  System.out.println("입력하삼..");
  
  int _byte;
  
  while((_byte=System.in.read()) != -1){

   if(_byte == 10 || _byte ==13) continue;   //10 스페이스바, 13 엔터
   if(_byte == 113 || _byte ==81) break; //알파벳 대문자......
   char c = (char)_byte;
   System.out.printf("%s(%d)", c, _byte); 
  }

 }

}

문2>주민번호 체크
     13자리의 숫자 스트링 중에서 앞에서부터 12자리의 숫자 스트링을 각 숫자로 분할하여 각 자리의 수에 가중치 2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5를 곱합니다.
     곱한수를 모두 더하여 총합을 구합니다.
     총합을 11로 나눈 나머지를 구합니다.
     그 나머지를 11에서 뺀 결과가 CHECK DIGIT 입니다.
    뺀 결과가 2자리수인 경우에는 2자리수를 10으로 나눈 나머지가 CHECK DIGIT가 됩니다.
    CHECK DIGIT의 값이 입력 숫자 스트링의 13번째 숫자와 같으면 "CORRECT", 다르면 "INCORRECT"를 출력합니다.

 

 

  int[] num = new int[]{2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5};
  
  System.out.print("13자리 주민번호 체크합니다. 입력하세요 :");
  Scanner sc = new Scanner(System.in);
  String str = sc.next();
  
  int hap=0;
  int chk=0;
 
  for(int i=0; i<num.length; i++){
   hap += str.charAt(i) * num[i];
  }
  if(11 - hap%11 > 9){
   chk = (11 - hap%11)%10+1;
   System.out.println(chk);
  } else {
   chk = 11 - hap%11+1;
   System.out.println(chk);
  }
  
  System.out.println(str.charAt(12));
  System.out.println(chk);
  if(chk == str.charAt(12)) {
  
   System.out.println("INCORRECT");
  } else {
   
   System.out.println("CORRECT");
   
  }

문) Java Programming을 단일 문자열로 입력받고, 입력받은 문자열에 대해서 역순으로 출력하시오.

 

  System.out.println("Java Programming 단일 문자 입력 : ");

 

  Scanner sc = new Scanner(System.in);
  String str = sc.nextLine();  // nextLine은 문자열에 공백이 있어도 공백까지 입력받음

                   // next는 공백이 들어가는 곳까지만 입력받음.. 그래서 공백이 있으면 전체 문자열을 입력받지 못한다.

 

 

  //문자열 길이 보려고 그냥 써놓음. 없어도 됨....
  System.out.println("str.length" + str.length());

 

  //역순 출력
  for(int i=str.length()-1; i>=0; i--){
      System.out.print(str.charAt(i));
  }

'2020년도 이전 > [WebSig] JAVA' 카테고리의 다른 글

주민번호 체크  (0) 2013.06.26

 

 

 

 

이미지 캡쳐하기 귀찮아서 재활용한 프로폼트 화면...

 

뭇튼 숫자를 프로폼트로 받는다..... 그후 수정은 안됨...

 

사실 귀찮아서 더이상 수정안함.... 뭐 간단한 소스이니 자체적으로 수정할수 있을겁니다.

 

<script language="javascript">
var cnt = 0;
var i;
var j;

 


i = eval(prompt("첫번째 숫자입력1",""));
j = eval(prompt("두번째 숫자입력2",""));

 


/*
function input(x){
 if(cnt == 0){
  i = x;
  cnt = 1;
  form1.text1.value = i;
 } else {
  j = x;
  cnt = 0;
  form1.text1.value = i + j;
 }
}
*/


function plus(){
 total = eval(i+ "+" +j);
 form1.text1.value = i + "+" + j + "=" + total;
 alert(i + "+" + j + "=" + total);
 document.bgColor="red";
}

function minus(){
 total = eval(i+ "-" +j);
  form1.text1.value = i + "-" + j + "=" + total;
 alert(i + "-" + j + "=" + total);
  document.bgColor="blue";
}

function div(){
 total = eval(i+ "/" +j);
  form1.text1.value = i + "/" + j + "=" + total;
 alert(i + "/" + j + "=" + total);
  document.bgColor="black";
}

function muti(){
 total = eval(i+ "*" +j);
  form1.text1.value = i + "*" + j + "=" + total;
 alert(i + "*" + j + "=" + total);
  document.bgColor="yellow";
}

 

</script>
</head>
<body>
<form name="form1">
  <input type="button"  value="0" onclick="input('0')" />
  <input type="button"  value="1" onclick="input('1')" />
  <input type="button"  value="2" onclick="input('2')" />
  <input type="button"  value="3" onclick="input('3')" />
  <input type="button"  value="4" onclick="input('4')" />
  <br>
  <input type="button"  value="5" onclick="input('5')" />
  <input type="button"  value="6" onclick="input('6')" />
  <input type="button"  value="7" onclick="input('7')" />
  <input type="button"  value="8" onclick="input('8')" />
  <input type="button"  value="9" onclick="input('9')" />
  <p>
    <input type="text" name="text1"  value="" />
  <p>
    <input type="button" value="덧셈" onclick="plus()" />
    <input type="button"  value="뺄셈" onclick="minus()" />
    <input type="button"  value="나눗셈" onclick="div()" />
    <input type="button"  value="곱셈" onclick="muti()" />
</form>
</body>
</html>

 

 

 

 

 

 

num1 = eval(prompt("구구단 숫자입력1",""));
num2 = eval(prompt("구구단 숫자입력2",""));
renum = num1;
var str = "구구단 표\n";

for(a=1; a<10; a++){
 while(num1<=num2){
  count = num1 * a;
  str +=  num1 + "*" + a + "=" ;
  if(count < 10)
  str +=   " " ;
  str += count + "   ";
  num1++;
 }
 num1= renum
 str += "\n";
}

alert(str);

 

--------------------------------------

 

다음은 세로로 출력하는 코드

 

 start=prompt("몇단 부터 시작하시겠습니다??","");

 end=prompt("몇단 까지 출력하시겠습니다??","");


 var string = "";

 for(i=start; i<=end; i++) {
  
  for(j=1; j<=9; j++) {
   
   string += "  " + start + " X " + j + "=" + start*j + "\n";
  }
  string +="\n\n";
   start++;
  if(start>end)
  break;
     document.write("<br>");
 }
 alert(string) ;

 

 

 

for문의 a++이 작동이 안되서 내가 야매?로 num1++;를 추가한것 같다.....

 

수업시간에 했던것인데 일단 출력물은 잘 나왔기 때문에 패스.....

 

 

혹 이 블로그를 보고 온 사람이 있다면 ㅇㅇ대생일지도 ㅎㅎㅎ

//단축키
var key = new Array();


// 여기부터 수정하세요. 필요한 갯수만큼 여려 라인을 넣으시면 됩니다.
// key['단축키'] = "이동할 페이지 주소"
key['h'] = "http://fs1025.mireene.com/index.html";
key['1'] = "http://fs1025.mireene.com/menu01/page1.html";
key['2'] = "http://fs1025.mireene.com/menu02/page1.html";
key['3'] = "http://fs1025.mireene.com/menu03/page1.html";
key['4'] = "http://fs1025.mireene.com/menu04/page1.html";
key['5'] = "http://fs1025.mireene.com/menu05/page1.html";


function getKey(keyStroke) {
if ((event.srcElement.tagName != 'INPUT') && (event.srcElement.tagName != 'TEXTAREA')){
isNetscape=(document.layers);
eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;
which = String.fromCharCode(eventChooser).toLowerCase();
for (var i in key)
if (which == i) window.location = key[i];
}
}
document.onkeypress = getKey;

 

//달력 시작
function setStyle(id,style,value)
{
    id.style[style] = value;
}

function calendar()
{
        var date = new Date();
        var day = date.getDate();
        var month = date.getMonth();
        var year = date.getYear();
        if(year<=200)
        {
                year += 1900;
        }
        months = new Array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12');
        days_in_month = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
        if(year%4 == 0 && year!=1900)
        {
                days_in_month[1]=29;
        }
        total = days_in_month[month];
        var date_today = year+'년'+months[month]+'월 '+day+'일';
        beg_j = date;
        beg_j.setDate(1);
        if(beg_j.getDate()==2)
        {
                beg_j=setDate(0);
        }
        beg_j = beg_j.getDay();
        document.write('<table class="cal_calendar" onload="<tbody id="cal_body"><tr><th colspan="7">'+date_today+'</th></tr>');
        document.write('<tr class="cal_d_weeks"><th>일</th><th>월</th><th>화</th><th>수</th><th>목</th><th>금</th><th>토</th></tr><tr>');
        week = 0;
        for(i=1;i<=beg_j;i++)
        {
                document.write('<td class="cal_days_bef_aft">'+(days_in_month[month-1]-beg_j+i)+'</td>');
                week++;
        }
        for(i=1;i<=total;i++)
        {
                if(week==0)
                {
                        document.write('<tr>');
                }
                if(day==i)
                {
                        document.write('<td class="cal_today" style="background-color:#e0e0e0;">'+i+'</td>');
                }
                else
                {
                        document.write('<td>'+i+'</td>');
                }
                week++;
                if(week==7)
                {
                        document.write('</tr>');
                        week=0;
                }
        }
        for(i=1;week!=0;i++)
        {
                document.write('<td class="cal_days_bef_aft">'+i+'</td>');
                week++;
                if(week==7)
                {
                        document.write('</tr>');
                        week=0;
                }
        }
        document.write('</tbody></table>');
      
        return true;
}
//달력 끝

 

//스네이크 텍스트
var x,y;
var step=10;
var flag=0;
var message="I LOVE DOKDO";
message=message.split("");
var xpos=new Array()
for(i=0; i<message.length-1; i++){
 xpos[i] = -50;
}

var ypos=new Array()
for(i=0; i<message.length-1; i++){
 ypos[i] = -50;
}

function handlerMM(e){
 x = (document.layers) ? e.pageX : document.body.scrollLeft+event.clientX;
 y = (document.layers) ? e.pageY : document.body.scrollLeft+event.clientY; 
 flag = 1;
}

function makesnake(){
 if(flag ==1 && document.all){
  for(i=message.length-1; i>=1; i--){
   xpos[i]=xpos[i-1]+step;
   ypos[i]=ypos[i-1];
  }
  xpos[0]=x+step;
  ypos[0]=y;
  
  for(i=0; i<message.length-1; i++){
   var thisspan = eval("span"+(i)+".style")
   thisspan.posLeft=xpos[i];
   thisspan.posTop=ypos[i];
  }
 }
 else if(flag ==1 && document.layers){
  for(i=message.length-1; i>=1; i--){
   xpos[i]=xpos[i-1]+step;
   ypos[i]=ypos[i-1];
  }
  xpos[0]=x+step;
  ypos[0]=y;
  for(i=0; i<message.length-1; i++){
   var thisspan = eval("document.span"+i)
   thisspan.left=xpos[i];
   thisspan.top=ypos[i];
  }
 }
 
 var timer=setTimeout("makesnake()", 30)
}

 

 

 

 

사용하고자 하는 html 파일에다가

 

<body onLoad="makesnake();" style="overflow:hidden;">

 

 

<!-- 스네이크 텍스트 -->
<script language="javascript">
for(i=0; i<=message.length-1; i++){
 document.write("<span id='span" + i + "' class='spanstyle'>")
 document.write(message[i])
 document.write("</span>")
}

if(document.layers){
 document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = handlerMM
</script>

+ Recent posts