Use java programming for the following questions to have the solutions ready within today Jan 3 2020 at or before 8:00PM GMT+8 time zone:
Question 5
A method secret() of a class F is shown below:
public int secret(String[] stringArray, int n) { int num = 0;
for (int i=0; i<stringArray.length; i++)
if (stringArray[i].indexOf("a", n) >= 0)
num++;
return num;
}
A program segment using the method is:
F f = new F();
String[] array01 = {"an", "easy", "exam", "on", "Java"}; System.out.println(f.secret(array01, 2)); array01 = new String[0];
System.out.println(f.secret(array01, 3));
a.
OUTPUT

b.
EXPLANATION
INPUT: secret method takes an array of strings and an integer, n
OUTPUT: secret method returns the number of strings that have letter 'a' in the strings from the index n

-- Please up vote or comment if you have any doubts.
Happy Learning!
Use java programming for the following questions to have the solutions ready within today Jan 3...
Use java programming for the following questions to have the solutions ready within today Jan 3 2020 at or before 8:00PM GMT+8 time zone: Question 10 Declare a local String variable id and initialize it with your 8-digit student ID in string form. What is the output of the following program segment? String str = id + " "; // two spaces System.out.println(str.indexOf("5") + " + " + str.substring(0,2) + "\n" + str.trim().substring(5)+ "#"); The class List below is in...
Use java programming for the following questions to have the solutions ready within today Jan 3 2020 at or before 7:00PM GMT+8 time zone: Question 13 Some service fees (% of asset amount) of two investment companies are shown in the following tables: Company A: Service Fee Type Fee Management Fee 1.5 Subscription Fee 5.0 Redemption Fee 1.0 Company B: Service Fee Type Fee Platform Fee 0.2 Management Fee 1.0 Subscription Fee 2.0 The above information is to be stored...
In Java Programming chapter 6 Make a class that represents a file. This class will have the ability to calculate the number of lines in that file and the ability to search through the file. UML diagram: -filename:String +FileStats(String fname) +getNumMatchingWords(String wordtoFind) : int +getNumLines() : int The getNumMatchingWords method will take a bit of text and determine how many lines contain that text. Make the comparison not care about case. View required output Test Case 1 Files in the...
Java questions
QUESTION 8 Assume the following classes are each defined in their own java files and compile public class A public void display { System.out.println("A's display"); public class B extends A{ public void display { System.out.println("B's display"); public class C extends A public void display { System.out.println("C's display"); public class D { public static void main(String args) { 3: int i = ((int)(Moth.random(* 10)) if (i == 0) a = new BO: else if (i == 1) a =...
Java programming How do i change this program to scan data from file and find the sum of the valid entry and count vaild and invalid entries The provided data file contains entries in the form ABCDE BB That is - a value ABCDE, followed by the base BB. Process this file, convert each to decimal (base 10) and determine the sum of the decimal (base 10) values. Reject any entry that is invalid. Report the sum of the values...
Using java socket programming rewrite the following program to handle multiple clients simultaneously (multi threaded programming) import java.io.*; import java.net.*; public class WelcomeClient { public static void main(String[] args) throws IOException { if (args.length != 2) { System.err.println( "Usage: java EchoClient <host name> <port number>"); System.exit(1); } String hostName = args[0]; int portNumber = Integer.parseInt(args[1]); try ( Socket kkSocket = new Socket(hostName, portNumber); PrintWriter out = new PrintWriter(kkSocket.getOutputStream(), true); BufferedReader in = new BufferedReader( new InputStreamReader(kkSocket.getInputStream())); ) { BufferedReader...
JAVA PROGRAMMING
I want to make sure I have learned the compareto statements
correct and other things. This was on my lecture slide today and I
don't understand the compare to regarding how they get values for
the strings. Please answer the following.
Suppose that s1, s2, and s3 are three strings, given as follows String s1 = "Welcome to Java". String s2 = "Programming is fun". String s3- "Welcome to Java" hat are the results of the following expressions?...
(Java with Netbeans) Programming. Please show modified
programming code for already given Main class, and programming for
code for the new GameChanger class.
// the code for Main class for step number 6 has already
been given, please show modified progrraming for Main class and
GameCHanger class, thank you.
package .games;
import java.util.Random;
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
System.out.println("Welcome to the Number Guessing Game");
System.out.println();
Scanner sc = new Scanner(System.in);
// Get upper...
Make a FLOWCHART for the following JAVA Prime Number Guessing Game. import java.util.Random; import java.util.Scanner; public class Project2 { //Creating an random class object static Random r = new Random(); public static void main(String[] args) { char compAns,userAns,ans; int cntUser=0,cntComp=0; /* * Creating an Scanner class object which is used to get the inputs * entered by the user */ Scanner sc = new Scanner(System.in); System.out.println("*************************************"); System.out.println("Prime Number Guessing Game"); System.out.println("Y = Yes , N = No...
hey dear i just need help with update my code i have the hangman program i just want to draw the body of hang man when the player lose every attempt program is going to draw the body of hang man until the player lose all his/her all attempts and hangman be hanged and show in the display you can write the program in java language: this is the code bellow: import java.util.Random; import java.util.Scanner; public class Hangmann { //...