19-6 / 24 Job: seeking membership card number and four

☞ operational requirements

☞ idea of ​​writing code

1, get keyboard input

2, with the acquired card number is divided by 1000 to give one thousand

3, with the acquired card number after the addition modulo 1000, then in addition to seeking one hundred 100

4, then 100 divided by modulo acquired membership card, then in addition to seeking ten 10

5, except that the membership card 10, seeking a bit

 

 

☞ Code Content

Circulation Package; 

Import java.util.Scanner;

/ **
* @author 9527
* /

// import scanned package

public class the Resume {
static Scanner Scanner new new SC = (the System.in);
public static void main (String [] args ) {
// input prompt
System.out.println ( "Please enter the four card number:");
// get the card number
int = sc.nextInt Card ();
// output required by topic
System.out.println ( "card number is:" + Card);
// divided by 1000, seek one thousand
int = Card Qian / 1000;
// card number modulo divided by the one hundred 1,000,100 seek
int bai = card% 1000/100 ;
// membership number 100 divided by the modulus 10 seeking ten
int Shi card% = 100/10;
// modulo 10 addition to the membership card
Card 10% GE = int;
// sum
int + SUM = Qian Shi Bai + + GE;
// output of one thousand, one hundred, ten, bit
System.out.println ( "one thousand bits is:" + qian + ", the hundreds digit is:" + bai + ", the tens digit is:" + shi + ", single digits is:" + GE);
System.out.println ( "everybody on the figures and:" + sum) ;
}
}

☞ operation results

 

☞ problems in the process of

1, the variable "qian" when the second knock, knock became "qina", can not run the program automatically prompts ------- need to write code to use IDEA

 

 



Guess you like

Origin www.cnblogs.com/twuxian/p/11078758.html