Answer:
public class Main
{
public static void main(String[] args) {
int userNum = 40;
while(userNum > 1){
userNum /= 2;
System.out.print(userNum + " ");
}
}
}
Explanation:
*The code is in Java.
Initialize the userNum
Create a while loop that iterates while userNum is greater than 1. Inside the loop, divide the userNum by 2 and set it as userNum (same as typing userNum = userNum / 2;). Print the userNum
Basically, this loop will iterate until userNum becomes 1. It will keep dividing the userNum by 2 and print this value.
For the values that are smaller than 1 or even for 1, the program outputs nothing (Since the value is not greater than 1, the loop will not be executed).
The direction of data transport is its built from the top and goes down and across the wire and read going up on the recieving computer?
True
False
which of the following are bee per frame attribute
Explanation:
where are the choices
The area tht includes all objects and elements in a chart in excel is called??
Answer:
Chart area
i hope this helps
ABC incorporated wants to implement a TCP/IP network for its only site. It has 180 employees and two buildings and requires Internet access for an e-mail server, a single Web server, a single FTP server, and two routers, each with a single high speed Internet interface. If the company wants to hold ISP costs to an absulate minumum, what kind of IP addresses should they primarily use
Answer:
A private IP address should be implemented but a PAT and a static NAT should be configured for the computers and the intermediate devices respectively.
Explanation:
There are two types of IP addresses, they are public and private addresses. The public address is an IP4 address routable on the internet while the private address is not routable.
Internet service providers do charge for the use of public IP addresses they render, which can be very costly. To reduce the company's expenses on the internet, the company is networked with private addresses and are mapped for network address translation ( NAT) which assigns a public global address to devices accessing the internet.
Write a program that reads in any number of MyStrings of characters from the user and determines if each MyString is a palindrome. The user will terminate each MyString by pressing the return (or enter) button. The user will indicate that there are no more MyStrings by entering "quit". The function must be recursive and must not call any other functions.
Answer:
Here is the recursive function:
bool isPalindrome(string& MyString,int start, int end){ // function that takes as argument a string and two arguments that are bounds indices
while(start < MyString.length() && !isalpha(MyString[start])){ //while loop continues to execute as long as start does not exceed the length of the string AND does not point to a alphabetic letter
start++; } // increments start by 1 moving it to point the next character
while(end >= 0 && !isalpha(MyString[end])){ //while loop continues to execute as long as end does not gets less than 0 AND does not point to a alphabetic letter
end--; } // decrements end by 1 moving it to point the next character backwards
if(start > end){ //the base case
return true;
} else { //recursive case
return ( ( toupper(MyString[start]) == toupper(MyString[end]) ) && isPalindrome(MyString,start+1,end-1)); } } //The recursive case is to AND the result of comparing the alphabetic letters at start and end with result of the function (called recursively) after without both of the letters
Explanation:
Here is the complete C++ program:
#include <iostream> //to use input output functions
#include <cctype> //functions to manipulate characters
using namespace std; //to identify objects as cin cout
bool isPalindrome(string&,int start, int end); // function prototype
int main(){ //start of main function
string MyStrings; //declare a string type variable to hold string of characters
cout<<"Enter a string : "; //prompts user to enter a string
getline(cin,MyStrings ); //gets and reads the string from user
while(MyStrings != "quit"){ // continues to take input from user until user enters quit
if(isPalindrome(MyStrings ,0,MyStrings.length()-1)== true){ //calls function that checks if the string is a palindrome
cout<<MyStrings<<" is a Palindrome\n";} //if the input string is a palindrome then display this message
else
{cout<<MyStrings<<" is not a Palindrome\n";} //if the input string is not a palindrome then displays this message
cout<<"Enter a string : "; //prompts user to enter a string
getline(cin,MyStrings); } } //reads a string from user
bool isPalindrome(string& MyString,int start, int end){ //function definition
while(start < MyString.length() && !isalpha(MyString[start])){
start++; }
while(end >= 0 && !isalpha(MyString[end])){
end--; }
if(start > end){
return true;
} else {
return ( ( toupper(MyString[start]) == toupper(MyString[end]) ) && isPalindrome(MyString,start+1,end-1)); } }
I will explain the working of the function:
First the start variable is pointed to the start of the MyString and the end variable points to the last character of MyString
while(start < MyString.length() && !isalpha(MyString[start]))
The above statement has a while loop which continues to execute as long as start does not exceed the string length and it does not point to a letter. It has a AND logical operator that means both the above condition have to be true in order to continue this while loop. Here isalpha() method is used that checks if the letter/character of MyString is an alphabet or not. At each iteration start is incremented to 1 to point the next character of MyString.
while(end >= 0 && !isalpha(MyString[end]))
The above statement has a while loop which continues to execute as long as end does not becomes less than 0 and it does not point to a letter, Here isalpha() method is used that checks if the letter/character of MyString is an alphabet or not. At each iteration end is decremented to 1 to point the next character of MyString in backward or in reverse order.
if(start > end){
The above statement is a base case which is the IF condition that checks if the start is greater than end. This basically shows that there are no more alphabetic characters and this base case returns true as it reads the same from both sides.
else {
return ( ( toupper(MyString[start]) == toupper(MyString[end]) ) && isPalindrome(MyString,start+1,end-1)); } }
The above statement is a recursive part. It uses AND logical operator and compares the characters at start and end with the result of the function after excluding both of the characters pointed by start and end.
The program along with its output is attached.
If you have a second Ethernet adapter, which network location is being used by the adapter?
Answer:
Public network
Explanation:
The network includes different networks and settings for sharing which are applied to the network which you are connected to.
A public network is being used by the adapter. The public network is a network that is unrestrictive. That is, any member of the public can easily have access to it and connect to the internet. Such a network exposed users to risks by exposing the connected devices.
In an event, it is when an object moves from a prior state to a subsequent state.
a. True
b. False
Answer:
a. True
Explanation:
Objects suffer inertia before a transition is achieved. Transition is the movement of an object from one state to another. But, this transition does not happen on its own. It is usually triggered by an event or series of events. This means that when the object moves from its prior state to a subsequent state, an event must have occurred to trigger the transition. Objects, therefore, depend on events or an outside force to remove their inertia. They are usually in a state of inertia until an outside stimulus stimulates them with some momentum.
Which of these is the largest?
terabyte
exabyte
gigabyte
kilobyte
PLEASE HELP
Answer: Exabyte
Explanation:
I took the Quiz
If someone you don”t know asks where you go to school, what should you do?
Answer:come up something that sounds real but is not true.
Explanation: The reason why is because they could look it up if you tod them the real answer and then follow you and kidnap you and they could do a school shooting it"s not lying it's not it's protecting your self and others.#bettersafethansorry
The right thing to do when someone you don't know asks where you go to school, is do not respond.
Why talking to stranger has its cons?The act of talking to Strangers is one that can help a person to know more about a thing but it also has its disadvantage.
Conclusively, note that someone asking you about where you school may want to harm you or do some really bad and as such it is better not to respond when someone you don't know asks where you go to school.
Learn more about school from
https://brainly.com/question/6947486
#SPJ2
2.13) A simple rule to estimate your ideal body weight is to allow 110 pounds for the first 5 feet of height and 5 pounds for each additional inch. Write a program that reads the data in the file and outputs the full name and ideal body weight for each person. In the next chapter, you will learn about loops, which allow for a more efficient way to solve this problem.
Answer:
import csv
def ideal_weight( filename ):
with open( "filename", "r" ) as file:
for row in csv.DictReader( file):
print ( "Name of person: ",row["name"] )
person_weight = ( 110 * row["height"] )/ 5
print ( "Ideal weight: ", person_weight )
Explanation:
The python source code above is a function which recieves a csv file argument, opens the file and reads each row an ordered dictionary. The function prints the name of each person in the file and their ideal weight.
Consider that an individual threat agent, like a hacker, can be a factor in more than one threat category. If a hacker breaks into a network, copies a few files, defaces a Web page, and steals credit card numbers, how many different threat categories does the attack fall into
How does Wireshark differ from NetWitness Investigator?
Answer is given below
Explanation:
Wireshark differ from NetWitness Investigator because Windshark shows a detailed view of individual packets. WireShark captures live traffic and displays the results at the packet level. Netwitness shows a high-level view and can be compared to the new packet capture NetWitiness Investigator provides a comprehensive overview of previously tracked traffic that can be used to view anomalies, compliance and attacks.Taking an online class doesn't require any special skills.
Please select the best answer from the choices provided
()T
()F
help pls
Answer:
F
Explanation:
It depends on whether the person has interest in it
The statement - "Taking an online class doesn't require any special skills" is false.
What is online class?An online class is a course that is delivered through the Internet. They are often delivered via a learning management system, where students may monitor their course curriculum and academic progress, as well as communicate with their classmates and course teacher.
When taking an online class, one must be alert and prompt. Furthermore, certain material may be obscure owing to a communication barrier between the student and teacher.
The student must be able to grasp what the teacher is saying in a short period of time, and self-teaching abilities should be strengthened in distance online education. As a result, the supplied assertion is untrue.
Learn more about online class here:
https://brainly.com/question/13649312
#SPJ2
Write a recursive method that returns the number of 1’s in the binary representation of N. Use the fact that this is equal to the number of 1’s in the representation of N/2, plus 1, if N is odd
Answer:
Here is the recursive method NoOfOnes :
public static int NoOfOnes(int N) { // method that takes number N as argument and returns the number of 1’s in the binary representation of N
if(N==0) { //base case 1
return 0; } //if the value of N is equal to 0 then method returns 0
else if(N==1){ //base case 2
return 1; } // if the value of N is equal to 1 then method returns 1
else if(N%2==1) { //if N is odd (recursive case)
return NoOfOnes(N/2)+1; } //calls method recursively and divides N by 2 plus 1
else{ //when N i even (recursive case)
return NoOfOnes(N/2); } } //calls method recursively and divides N by 2 to return number of 1's in binary representation of N
Explanation:
Here is the complete JAVA program:
import java.util.Scanner; //to take input from user
public class Main {
public static int NoOfOnes(int N) {//the method that takes number N as argument and returns the number of 1’s in the binary representation of N
if(N==0) { //base case 1
return 0; }
else if(N==1){//base case 2
return 1; }
else if(N%2==1) {//recursive case when N is odd
return NoOfOnes(N/2)+1; }
else{ //recursive case when N is even
return NoOfOnes(N/2); } }
public static void main(String[] args) { //start of main function
Scanner scan = new Scanner(System.in); //creates object of Scanner
System.out.print("Enter n: ");//prompts user to enter value of N
int n = scan.nextInt(); //reads the value of n from use
System.out.print("number of 1’s in the binary representation of " +n+" is: "+NoOfOnes(n)); } } //displays the number of 1’s in the binary representation of n
i will explain the working of the function with an example
Lets say N = 6
if(N==0) this statement evaluates to false as N is not 0
else if(N==1 this statement also evaluates to false as N is not 1
else if(N%2==1) this statement also evaluates to false because N is not odd. If we take modulo of 6 by 2 then the remainder is 0 because 6 is completely divisible by 2 so N = 6 is an even number. So the else part is executed:
else{
return NoOfOnes(N/2);}
This statement calls NoOfOnes recursive by passing N/2 to the method. So this becomes:
return NoOfOnes(6/2)
6/2 = 3
NoOfOnes(3)
Now this method is called again with the value of N = 3. Since 3 is an odd number so the recursive case of odd N is executed:
else if(N%2==1) {
return NoOfOnes(N/2)+1; }
NoOfOnes(3/2)+ 1
NoOfOnes(1) + 1
Now the method is called again with value of N=1. The base case 2 is executed because N==1 which returns 1
else if(N==1){
return 1; }
So this becomes
NoOfOnes(1) + 1
1 + 1
= 2
So the method return 2 as the number of 1’s in the binary representation of N = 6
Hence the output of the above program with N = 6 is
number of 1’s in the binary representation of 6 is: 2
how to write a function that counts the letters in a string in C?
Answer:
Here is the C function that counts the letters in a string:
int LetterCount(char string[]){ //function to count letters in a string passed as parameter
string[100]; // char type string with size 100
int i, letters; // letter variable stores the count for no. of letters in string
i = letters = 0; //initialize variables i and letters to 0
while (string[i] != '\0') { // loop iterates through the entire string until end of string is reached
if( (string[i] >= 'a' && string[i] <= 'z') || (string[i] >= 'A' && string[i] <= 'Z') ) { // if condition checks the letters in the string
letters++; } // increments 1 to the count of letters variable each time a letter is found in the string
i++; } //increments value of i to move one character forward in string
printf("Number of Letters in this String = %d", letters); // displays the number of letters in the string
return 0; }
Explanation:
Here the question means that the function should count the letters in a string. So the letters are the alphabets from a to z and A to Z.
Here is the complete program:
#include <stdio.h> // to use input output functions
int LetterCount(char string[]){ // method that takes a character string as parameter and counts the letters in the string
string[100];
int i, letters;
i = letters = 0;
while (string[i] != '\0') {
if( (string[i] >= 'a' && string[i] <= 'z') || (string[i] >= 'A' && string[i] <= 'Z'))
{letters++; }
i++; }
printf("Number of Alphabets in this String = %d", letters);
return 0;}
int main(){ // start of main function
char string[100]; //declares a char array of string
printf("Please Enter a String : "); //prompts user to enter a string
fgets(string,100,stdin); //get the input string from user
LetterCount(string); } // calls method to count letters in input string
I will explain this function with an example
Lets suppose the user input "abc3" string
string[100] = "abc3"
Now the function has a while loop that while (string[i] != '\0') that checks if string character at i-th position is not '\0' which represents the end of the character string. As value of i = 0 so this means i is positioned at the first character of array i.e. 'a'
At first iteration:
i = 0
letter = 0
if( (string[i] >= 'a' && string[i] <= 'z') || (string[i] >= 'A' && string[i] <= 'Z') ) if condition checks if the character at i-th position of string is a letter. As the character at 0-th position of string is 'a' which is a letter so this condition evaluates to true. So the statement letter++ inside if condition executes which increments the letter variable to 1. So the value of letter becomes 1. Next statement i++ increments the value of i to 1. So i becomes 1. Hence:
i = 1
letter = 1
At second iteration:
i = 1
letter = 1
if( (string[i] >= 'a' && string[i] <= 'z') || (string[i] >= 'A' && string[i] <= 'Z') )
if condition checks if the character at i-th position of string is a letter. As the character at 1st position of string is 'b' which is a letter so this condition evaluates to true. So the statements letter++ inside if condition and i++ executes which increments these variables to 1. Hence:
i = 2
letter = 2
At third iteration:
i = 2
letter = 2
if( (string[i] >= 'a' && string[i] <= 'z') || (string[i] >= 'A' && string[i] <= 'Z') )
if condition checks if the character at i-th position of string is a letter. As the character at 2nd position of string is 'c' which is a letter so this condition evaluates to true. So the statements letter++ inside if condition and i++ executes which increments these variables to 1. Hence:
i = 3
letter = 3
At fourth iteration:
i = 3
letter = 3
if( (string[i] >= 'a' && string[i] <= 'z') || (string[i] >= 'A' && string[i] <= 'Z') )
if condition checks if the character at i-th position of string is a letter. As the character at 3rd position of string is '3' which is not a letter but a digit so this condition evaluates to false. So the statement letter++ inside if condition does not execute. Now i++ executes which increments this variable to 1. Hence:
i = 4
letter = 3
Now the loop breaks because while (string[i] != '\0') condition valuates to false as it reaches the end of the string.
So the statement: printf("\n Number of Letters in this String = %d", letters); executes which prints the value of letters on the output screen. Hence the output is:
Number of Letters in this String = 3
The human resource (HR) manager stores a spreadsheet with sensitive personal information on her local workstation. The spreadsheet is the only file with sensitive data and the name of the spreadsheet does not change. Which Windows encryption feature would ensure this one file is always stored on the disk in encrypted format
Answer:
WAHTSTFYHHTHIEBWIBWDKF
Explanation:thx
FOR A SEC
What converts source code onto object code
Answer:
The Compiler
Explanation:
A compiler takes the program code (source code) and converts the source code to a machine language module (called an object file). Another specialized program, called a linker, combines this object file with other previously compiled object files (in particular run-time modules) to create an executable file
does Buzz or APEX shows all your due assignments on the left of the main home screen?
Answer:
go to your dashboard and press the number under grade to date (your percentage in the class) and it should show all your assignments that you have done and that still need to be done
In the file MajorSalary, data have been collected from 111 College of Business graduates on their monthly starting salaries. The graduates include students majoring in management, finance, accounting, information systems, and marketing. Create a PivotTable in Excel to display the number of graduates in each major and the average monthly starting salary for students in each major.
Answer:
The pivot table is attached below
Explanation:
procedure used to create the Pivot Table
select insert from worksheet Ribbonselect pivot tableselect the range of Dataselect "new worksheet "select Major as row heading and the summation symbol to count the majorinput variables given in their right cellsafter this procedure the table is successfully created
Attached below is the Pivot Table in Excel displaying The number of graduates in each major and average monthly salaries
When using SSH to remotely access a Cisco router, can you see the terminal password?
Answer:
No, you can't.
Explanation:
SSH is an acronym for Secure Socket Shell and is a networking protocol used for providing remote authentication through a public-key cryptography over an unsecured network such as the internet.
Hence, it is a network protocol that is commonly implemented by using a client-server model; where a computer acts as a SSH client while the other network device acts as the host or SSH server.
When using SSH to remotely access a Cisco router, you cannot see the terminal password because it is Linux based and encrypted through the use of symmetrical encryption, asymmetrical encryption or hashing
An optimal solution to an Operations problem will yield:____________
Answer:
The best solution.
Explanation:
In the operations and management of systems such as manufacturing, transport, government, network, service systems, we encounter various type of challenges and problems. These challenges and problems must be fixed or resolved as soon as possible in order to restore normal operations, as well as ensuring that the solution mitigates the occurrence of such problems in the future.
Hence, an optimal solution to an Operations problem will yield the best solution because it gives the maximum functionality. For instance, an optimal solution is considered to be the best solution because it gives the least cost, effective and efficient or gives the most profit.
Why is it important to use correct posture while typing
Answer:
is to sit up straight
Explanation:
more blood flows through ur head and u can procecs more information and be more active on your work
A photograph is created by what?
Silver, Shutters, Light, Mirrors
Answer:
Mirror
Explanation:
No explanation
Answer:
I think your answer is Light. Its not silver because thats
just what the camera is made of. Shutters I don't know what it does. Im positive that it is Light!
____ is the number of processes that are completed per time unit.
A) CPU utilization
B) Response time
C) Turnaround time
D) Throughput
Answer: D, Throughput
Explanation: Throughput is a measure of how many units of information a system can process in a given amount of time.
. (a) Prove or disprove carefully and in detail: (i) Θ is transitive and (ii) ω is transitive. (b) Assume n is a positive integer. Algorithm A(n: int) int z = 0; int temp = 0; for (int i = 0; i < n ; i++) { for (int j = 0 ; j < i ; j++) { int temp = i + j ; int z = z + temp; } } System.out.println(z) ; What is the input size for Algorithm A? Analyze carefully and explicitly the time complexity of A in terms of the input size. Show all steps. Is A a polynomial time algorithm? Justify your answer.
Answer:
The Following are the solution to this question:
Explanation:
In Option a:
In the point (i) [tex]\Omega[/tex] is transitive, which means it converts one action to others object because if [tex]\Omega(f(n))=g(n)[/tex] indicates [tex]c.g(n)<=f(n)[/tex]. It's true by definition, that becomes valid. But if [tex]\Omega(g(n))=h(n)[/tex], which implies [tex]c.h(n)<=g(n)[/tex]. it's a very essential component. If [tex]c.h(n) < = g(n) = f(n) \[/tex]. They [tex]\Omega(f(n))[/tex] will also be [tex]h(n)[/tex].
In point (ii), The value of [tex]\Theta[/tex] is convergent since the [tex]\Theta(g(n))=f(n)[/tex]. It means they should be dual a and b constant variable, therefore [tex]a.g(n)<=f(n)<=b.g(n)[/tex] could only be valid for the constant variable, that is [tex]\frac{1}{a}\ \ and\ \ \frac{1}{b}[/tex].
In Option b:
In this algorithm, the input size value is equal to 1 object, and the value of A is a polynomial-time complexity, which is similar to its outcome that is [tex]O(n^{2})[/tex]. It is the outside there will be a loop(i) for n iterations, that is also encoded inside it, the for loop(j), which would be a loop[tex](n^{2})[/tex]. All internal loops operate on a total number of [tex]N^{2}[/tex] generations and therefore the final time complexity is [tex]O(n^{2})[/tex].
Select the correct answer from each drop-down menu. What skills should Tara hone to get a job in testing? Tara is a recent computer science graduate. After completing a three-month internship at an IT firm, she decides to become a tester. Since Tara is trying to get a job as a tester, she should concentrate on improving her and skills in order to get the desired job.
Answer:
heres your answer
Explanation:
have a good day <3
Mr. Edwards, a game designer, creates a game that draws attention to how real estate developers are causing the natural habitat of an
endangered species of bird to decline. Which option best describes this game?
ОА.
It is an entertainment-based game.
ОВ.
It is an advergame.
It is an educational game.
Ос.
OD.
It is an issues-based game.
Answer:
OB
Explanation:
Mr. Edwards the game designer is making it for education purposes so you can learn, it is for learning. So you know endangered species of birds.
Match each of the following servers to its definition:
1. DNS
2. Web
3. E-mail
4. DHCP
5. Commerce
a. enables users to purchase items over the Internet
b. specifically deals with the SMTP communication method
c. translates a domain name into an IP address
d. delivers HTML documents on request
e. assigns users IP addresses for the duration of a session
Answer:
1. Commerce
2. E-mail
3. DNS
4. Web
5. DHCP
Explanation:
A server can be defined as a dedicated system either software or hardware that is used to provide specific services to other devices or programs, which are referred to as the clients. The following are the functions of various functions of server in cloud computing services;
a. Commerce: enables users to purchase items over the Internet.
b. E-mail: specifically deals with the SMTP communication method.
c. DNS: translates a domain name into an IP address.
d. Web: delivers HTML documents on request.
e. DHCP: assigns users IP addresses for the duration of a session.
Write an application that determines which, if any, of the following files are stored in the folder where you have saved the exercises created in this chapter: autoexec.bat, CompareFolders.java, FileStatistics.class, and Hello.doc. The program should display the number of files found. For example, if two of the files are found display the message 2 of the files exist.
Answer:
Here is the JAVA application that determines which if any of the following files are stored in folder where you have saved the exercises created.
import java.nio.file.*; // used to manipulate files and directories
import java.nio.file.attribute.*; //used to provide access to file and file attributes
import static java.nio.file.AccessMode.*; // provides access modes to test the accessibility of a file
import java.io.IOException; //for exception handling
class FindSelectedFiles {
public static void main(String[] args) { //start of main function
Path f1 = Paths.get("/root/sandbox/autoexec.bat"); //creates Path object f1 using Paths.get() method and this instance contains the file name and directory list used to construct the specified path
Path f2 = Paths.get("/root/sandbox/CompareFolders.java"); //creates Path object f2 using Paths.get() method and this instance contains the file name and directory list used to construct the specified path
Path f3 = Paths.get("/root/sandbox/FileStatistics.class"); //creates Path object f3 using Paths.get() method and this instance contains the file name and directory list used to construct the specified path
Path f4 = Paths.get("/root/sandbox/Hello.doc"); //creates Path object f4 using Paths.get() method and this instance contains the file name and directory list used to construct the specified path
int count=0; //used to count the number of files found
try{ // used to define a code chunk to be tested for errors
f1 = Paths.get("/root/sandbox/autoexec.bat"); // Converts a path string when joined form a path string to a Path
System.out.println(f1); //prints the file
/* getFileSystem method is used to return the file system that created this Path object f1 and checkAccess Verifies access and throws exception if something is wrong
f1.getFileSystem().provider().checkAccess(f1);
System.out.println(f1 +" File Exists\n"); //if file exists then displays this message
count++; } //adds 1 to the count of number of files found
catch (IOException e) { //a code chunk to be executed if error occurs in the try part
System.out.println("File Doesn't Exist\n"); } //if file not found displays this message
try{ //works same as above try block but for 2nd folder and object f2
f2 = Paths.get("/root/sandbox/CompareFolders.java");
System.out.println(f2);
f2.getFileSystem().provider().checkAccess(f2);
System.out.println(f2 +" File Exists\n");
count++; }
catch (IOException e) {
System.out.println("File Doesn't Exist\n"); }
try{ //works same as above try block but for 3rd folder and object f3
f3 = Paths.get("/root/sandbox/FileStatistics.class");
System.out.println(f3);
f3.getFileSystem().provider().checkAccess(f3);
System.out.println("File Exists\n");
count++; }
catch (IOException e) {
System.out.println("File Doesn't Exist\n"); }
try{ //works same as above try block but for 4th folder and object f4
f4 = Paths.get("/root/sandbox/Hello.doc");
System.out.println(f4);
f4.getFileSystem().provider().checkAccess(f4);
System.out.println(f4 +" File Exists\n");
count++; }
catch (IOException e) {
System.out.println("File Doesn't Exist\n"); }
System.out.println(count+" of the files exist"); } } //displays the number of files found
Explanation:
If you want to directly pass the file name as argument to Paths.get() method then you can use the following code:
Path f1 = Paths.get("autoexec.bat");
Path f2 = Paths.get("CompareFolders.java");
Path f3 = Paths.get("FileStatistics.class");
Path f4 = Paths.get("Hello.doc");
The program determines if any, of the files from autoexec.bat, CompareFolders.java, FileStatistics.class, and Hello.doc. are stored in the folder. If a file is found then the program displays the message File exists and add 1 to the count variable each time a file is found. If all the files are found then the program returns the count as 4 otherwise the program display the number of files found by displaying the computed final value of count in the output. Lets say all the files are found then the output of the above program is:
autoexec.bat autoexec.bat File Exists
CompareFolders.java CompareFolders.java File Exists
FileStatistics.class File Exists
Hello.doc Hello.doc File Exists
4 of the files exist
The hardware to keep the output data when finished is a