Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Plz answer all the questions on both pictures ooo cricket 1:58 AM isidore.udayto

ID: 3883514 • Letter: P

Question


Plz answer all the questions on both pictures

ooo cricket 1:58 AM isidore.udayton.edu 49 ISIDORE TOOLS SITES are the v the String Hello; string t = ·World". a. s.length tlength) b. s.substring, 2) c. s.substring(s.length2, s.length)) R2.11 Find at least five compile-time errors in the following program. public class HasErrors public static void main) System.out.print (Please enter two numbers:) System.out printline( "The sum isx y) . R2.12 Find three run-time errors in the following program. public class HasErrors public static void main(String args) int x0 int y 0; Scanner in new Scanner("System.in) System.out print( "Please enter an integer:) x = in. read!nt(); System.out.print("Please enter another integer:) x = in.readInt(); System.out.println( The sum is"x y)i . R2.13 Consider the following code segment.

Explanation / Answer

R2.8

a. s.length()+t.length()->10

b. s.substring(1,2)->e

c. s.substring(s.length()/2,s.length()->llo

d. s+t->HelloWorld

e. t+s->WorldHello

R2.11

1. public static void main();--> requires a body

2. System.out.print(Please enter two numbers:) --> need semicolon, need " beginning and ending

3. in must be declared

4. x must be declared

5. y must be declared

R2.12

1. Scanner in=new Scanner("System.in");-->cannot be write like this Scanner scanner=new Scanner(System.in);

2. x=in.nextInt();--> for the above thing raises input mismatch exception

3. y=in.nextInt();--> for the above thing raises input mismatch exception

R2.13

doubles use IEEE 754 floating point arithmetic, which is inaccurate.

rewrite the code as

double purchase = 19.93f;

double payment = 20.00f;

double change = payment - purchase;

System.out.printf("%.3f",change);

R2.14

2--> integer value

2.0-> floating value

'2'-> character value

"2"-> string value

"2.0"-> string value

R2.15

a. adds the x+x and assigns to y

b. concatenates the as s+s and assigns to t

R2.18

int a = 23456;

int b = (int) (a / Math.pow(10, (int) Math.log10(a)));

System.out.println("First digit-->" + b);

System.out.println("Last digit-->" + (a % 10));

OUTPUT:

First digit-->2

Last digit-->6