Question: Please answer the following questions in the java language. 1. Create a method (function) with an int type parameter. This function will print out prime

Please answer the following questions in the java language.

1. Create a method (function) with an int type parameter. This function will print out prime numbers on screen range from 0 to the parameter value. The function will return the number of the prime numbers. Use main() method to test if your function works well.

2. Read and try to understand the following example:

Please answer the following questions in the java language. 1. Create a

Summarize the using of Scanner: how to read data from keyboard, how to read data from a file,

and how to read data from a web page.

3. Whats the output of the following program:

public class NewClass

{

public static void main(String[] args)

{

String s1 = "Computer Science";

int x = 262;

String s2 = s1 + " " + x;

String s3 = s2.substring(10,17);

String s4 = " is fun";

String s5 = s2 + s4;

System.out.println("s1: " + s1.replace("e", "E"));

System.out.println("s2: " + s2.toLowerCase());

System.out.println("s3: " + s3);

System.out.println("s4: " + s4.toUpperCase());

System.out.println("s5: " + s5);

//showing effect of precedence

x = s1.indexOf("e",9);

int y = s1.indexOf("e");

String s6 = x + y + "total";

String s7 = "total " + x + y;

String s8 = " " + x + y + "total";

System.out.println("s6: " + s6);

System.out.println("s7: " + s7);

System.out.println("s8: " + s8);

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!