Java Programming Job c.njupt.edu.cn Java implementation Third job

Source: Internet
Author: User
Tags array definition

Wang Li "Java language programming 3rd time Job (2018)" Detailed
      Job Result Details
Score: 100 Selection score: 601. The following definition statement is provided: String s1= "My cat"; int M=s1.compareto ("My A Cat"); the value of M after the statement is executed ()A.2b.1c.0d.-2 the correct answer is: A2. Statement string S1=new string ("Hello"); String S2=new string ("Hello"); System.out.println (S1==S2); SYSTEM.OUT.PRINTLV (s1.equals (S2)); The output after execution is ()A.hello Falseb.hello Truec.hello hellod.false True The correct answer is: D3. Execute the following statement int[] lx={2,3,4,5}; lx[3]=lx[3]==--lx[0]?++lx[1]:lx[2]--; After the element values for the array lx are ()a.1,2,3,4b.1,3,3,3c.1,2,3,3d.1,3,3,4 the correct answer is: D4. In an application defined array a:int[] a={1,2,3,4,5,6,7,8,9,10}, in order to print the last array element of the output array A, the following correct code is ()A.system.out.println (a[10]); B.system.out.println (a[9]); C.system.out.println (A[8]);D. System.out.println (A[a.length]); the correct answer is: B5. There is a definition statement int a[]={36,72,99}; The following describes the error for this statement ()A. The statement defines a one-dimensional array named A; the B.A array has 3 elements; C. Each element in the array is an integer, and the subscript of the elements of the D.A array is; the correct answer is: D6. The following about the array definition statement is incorrect ()A.float f[]=new{2.4f,3.5f,5.7f,7.9f}; B.int a[]={1,2,3,4,5}c.double[]d=new double[10];D. int[]a2; The correct answer is: a7. After the following statement sequence is executed, the value of C is () int a=3,b=4,c=0; while (a++ < (--b)) ++c;A.0b.1c.2d.3 the correct answer is: A8. After the following statement sequence is executed, the value of A is () int a=1; for (int i=5;i>0;i-=2) a*=i;a.0b.1c.15d.60 the correct answer is: C9. After the following statement sequence is executed, the value of C is () int a=10,b=18,c=30; switch (b-a) {case 8:c++; case 9:c+=2; case 10:c+=3; default:c/=b;} a.31b.32c.2d.33 the correct answer is: C10. Set A, b is an int variable, C, D is a fload type variable, ch is a char type variable, and all variables are assigned values, the following correct switch statement is ()A.switch (A+B); {...} B.switch (ch+1) {...} C.switch ch {...} D.switch (c+d) {...} The correct answer is: B11. After the following statement sequence is executed, the value of C is () int a=4,b=5,c=9,d=6; if (a>b| | C<D) c--; else C + +;A.6b.10c.8d.9 the correct answer is: B12. After the following statement sequence is executed, the value of C is () int a=6,b=3,c=5; if (a==b) C+=a;else c=++a*c;a.15b.25c.35d.45 the correct answer is: C13. After the following statement sequence is executed, the value of the C variable is () int a=2,b=4,c=5; if (a<--b) c*=a;a.5b.20c.15d.10 the correct answer is: D14. After the following sequence of statements is executed, the value in the CH1 variable is () Char ch1= ' A ', ch2= ' B '; if (CH1+2<CH2) ++ch1;A. ' A ' B. ' B ' c.ad. b The correct answer is: A15. In the following options, the valid assignment statement is ()a.++m!=n--; B.++m; c.m=m+1=5;d.m==1; The correct answer is: B16. There is a definition of "int a=22;long b=56;", the following assignment is incorrect statement is ()A.a=b; b.b= (long) A; c.a= (int) b;d.b=a; the correct answer is: a17. The following option, () is the correct output result int m=2,n=1; m+=m-=n; System.out.println ("m=" +m);A.m=1b.m=2c.m=3d.m=4 the correct answer is: C18. The following statement sequence executes after the result is () int a=10,b=4,c=20,d=6; System.out.println (a++*b+c*--d);a.144b.140c.28d. Unable to execute the correct answer is: B19. If the variables in the following options are defined correctly, the illegal expression is ()a.a>4==6<1; B. ' N '-3; C. ' A ' =8;d. ' A '%6 correct answer is: C20. Suppose a is a variable of type int that has been declared and assigned an initial value, then the assignment statement for A is correct ()A.int a=6; b.a==3; c.a=3.2f;d.a+=a*3; The correct answer is: D programming question score: 40print a few days a month score: 10/10
Import Java.util.Scanner;/*** @Author liguo* @Description * @Data 2018-04-03*/PublicClassMain {PublicStaticvoidMainString[] (args) {int year;int month;Int[] A = {1,3,5,7,8,10,12};Int[] B = {4,6,9,11}; Scannerin =New Scanner (System.in); Year =In.nextint (); month =In.nextint ();Judging February, consider leap year conditionsif (month = =2) {if (year%100! =0 && Year%4 = =0 | | Year%400 = =0) System.OUT.PRINTLN (Year + "-29"); else System. out.println (year +  "-" + month +  "-28 " ); } //Judge 31-day situation for (int element:a) { if (month = = Element) {System. "-" + month +  " -31");} //Judge 30-day situation for (int element:b) { if (month = = Element) {System. "-" + month +  " -30");}}}    
4-3-200 sub-system score conversion grade Score: 10/10
Import Java.util.Scanner;/*** @Author liguo* @Description read a percentile score x (0 < = x < = 100) from the keyboard and convert it to a grade score output. The subject is required to be implemented in the C and Java languages using the switch branch. * Grades (Percentile results) * A (90<=x<=100) * B (80<=x<90) * C (70<=x<80) * D (60<=x<70) * E (0<=x<60) * @Data 2018-04-03*/PublicClassMain {StaticvoidJudgeint mark) {Char degree =' A ';int temp = MARK/10;if (temp >=0 && Temp <6) degree =' E ';if (temp = =6) degree =' D ';if (temp = =7) degree =' C ';if (temp = =8) degree =' B ';if (temp = =9 | | temp = =) degree =' A '; System.Out.println (Mark +"--" + degree); }PublicStaticvoidMainString[] (args) {int temp; Scannerin =New Scanner (System.in);int x =in.nextint (); temp = x/10; if (temp >= 0 && temp <  6) temp = 5; switch (temp) {case 5:judge (x); Span class= "Hljs-keyword" >break; case 6:judge (x); break; case 7:judge (x); break; case 9:judge (x); break; case 10:judge (x); break;} }} 
solving piecewise function scores with an IF statement: 10/10
Import Java.util.Scanner;/*** @Author liguo* @Description piecewise Function Solution: Enter x to calculate and output y values: * y=x+100 (when x) * y= x (when 2 0≤x≤100) * Y=X-100 (when X is 10 0) * @Data 2018-04-03*/PublicClassMain {Publicstatic void main (string[" args) {double x, y; Scanner in = new Scanner (System. in); x = in.nextdouble (); if (x < 20) y = x + 100; else if (x >= Span class= "Hljs-number" >20 && x <= 100) y = x; else y = x-100; System. out.printf ( "x=%.2f,y=%.2f", X, y);}}      
2-2 Mixed-type data format input score: 10/10
Import Java.util.Scanner;/*** @Author liguo* @Description Enter the floating-point number 1, Integer, character, and floating-point number 2 in a row, separated by 1 spaces. * Input Description * Enter the floating-point number 1, Integer, character, floating-point number 2 in the order given in a row, separated by 1 spaces. * Output Description * Output in a row in the order of characters, integers, floating point number 1, floating point number 2, where the floating-point number retains 2 digits after the decimal point. * @Data 2018-04-03*/PublicClassmain {public static void main (string[] args) {Scanner in = new Scanner (system.< Span class= "Hljs-keyword" >in); double d1 = in.nextdouble (); in.nextint (); String s = in.next ();  char C = s.charat (0); in.nextdouble (); System. out.printf ( "%c%d%.2f%.2f", C, I, D1, D2);}}    
3-4-1A calculates the number of digits and scores of three digits: 10/10
Import Java.util.Scanner;/*** @Author liguo* @Description Enter any three-digit integer from the keyboard, write the program to calculate the digits and the number of the integer. Input description Enter a three-digit integer output description * @Data 2018-04-03*/Publicclass main {public static void  Main (string[] args) {Scanner in =  New Scanner (System. in); int temp = in.nextint (); temp = Math.Abs (temp); int a = Temp/100; int B = temp/10%10; int C = temp%10; int sum = a+b+c; System. out.println (sum);}}           

Java Programming Job c.njupt.edu.cn Java implementation Third job

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.