Answer:
// program in java.
// package
import java.util.*;
// class definition
class SquareDisplay
{
// main method of the class
public static void main (String[] args) throws java.lang.Exception
{
try{
// variable
int num;
// scanner object to read input
Scanner scr=new Scanner(System.in);
System.out.print("Enter an integer in the range of 1-15:");
// read integer from user
num=scr.nextInt();
// read until input is not in range 1-15
while(num<0 || num>15)
{
System.out.print("wrong input!!enter again:");
// read again
num=scr.nextInt();
}
// print square of X
for(int a=1;a<=num;a++)
{
for(int b=1;b<=num;b++)
{
System.out.print("X");
}
System.out.println();
}
}catch(Exception ex){
return;}
}
}
Explanation:
Read an integer from user and assign it to variable "num".Check if input is not in range 1-15 then ask again until user enter a number between 1-15 only.Then print a square of character "X" with the help of two nested for loops.
Output:
Enter an integer in the range of 1-15:-4
wrong input!!enter again:20
wrong input!!enter again:4
XXXX
XXXX
XXXX
XXXX
164.109.0.0/18
---------------------------------
Answer:
The answer is "Option D".
Explanation:
Trojan program is a malicious code that is also known as a virus. It is a rootkit, that aims to infect the computer to hide or obscure an object. These programs are mainly used to download additional content, such as additional pieces of malware, to the infected computer, and other options are wrong that can be defined as follows:
- In option A, It is not correct, this option infects the system.
- In option B, It is used for infects another computer that's why it is incorrect.
- In option C, It is incorrect because it is used in cybersecurity.
Answer:
Hi there! The question can easily be implemented by iterating through the array list an using the "startswith()" function of the String class. Please find explanation below.
Explanation:
We can write the code as below into a file called starts_with.py and run it from the command line. Sample input is also provided with results.
starts_with.py
import sys;
def starts_with(prefix, wordlist):
for e in wordlist:
if e.lower().startswith(prefix.lower()):
starts_with_array.append(e);
starts_with_array = [];
prefix = input("Enter prefix: ");
wordlist = input("Enter word list: ");
wordlist = wordlist.split(',');
starts_with(prefix, wordlist);
print(starts_with_array);
Usage with Result
> starts_with.py
> Enter prefix: Fun
> Enter word list: Funtastic,Fun,Test,No
> ['Funtastic', 'Fun']
A. Financial, because the rest seem to be health related.