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

Write a Java program to perform the following tasks: Prompt the user for the pat

ID: 3666171 • Letter: W

Question

Write a Java program to perform the following tasks: Prompt the user for the path of the directory where you store your Java source files. Prompt the user to enter the number of Java and non-Java files in that directory. Output the name of the root-level directory. Output the name of the leaf-level directory. Output the name of the directory containing “.class” files. Output the number of “.class” files in the “bin” directory. Make sure that you follow the sample session below: Where is your source directory? C:UsersjsmithworkspaceCSC200src (Make sure your code can also handle C:my_login_id_isYouKnowWhoworkspacePotion_Makingsrc.) How many Java files and non-Java files do you have in the above directory? 4 6 Now I know: Your root-level directory is “C:.” Your leaf-level directory is “…src.” Your login name is “jsmith.” Your ‘.class’ files are in: C:UsersjsmithworkspaceCSC200in. You have a total of 10 files in your source directory. It's better that you move those 6 non-Java files to the “C:Usersjsmith emp” directory.

Explanation / Answer

import java.io.*;

import java.util.*;

public class DemoDirStructure

{

string path;

int numJava, numNonJava;

System.out.println("enter the path of directory where you store your java source files");

Scanner s =new Scanner(System.in);

path=s.readLine();

System.out.println("enter number of Java and non-Java files in that directory");

numJava= Integer.parseInt(s.readLine());

numNonJava= Integer.parseInt(s.readLine());

for(int i=0;i<path.length();i++)

{

string root;

while(path.charAt(i)!='')

{

root =path.charAt(i);

}

System.out.println("Now I know : your root directory is:"+root);

for(int i=path.length();i>0;i--)

{

string leafDir;

while(path.charAt(i) != '')

{

leafDir= path.charAt(i);

}

}

System.out.println("your leaf directory is"+leafDir);

string actualReplace= "bin";

for(int i=path.length();i--)

{

for(int j=0;j<actualReplace.length();j++)

{

while(path.charAt(i) !='')

{

path.charAt(i) = actualReplace(j);

}

}

}

System.out.println("your class file is present at :"+path);

System.out.println("total number of files present in your specified path are:"+(numJava+numNonJava));

} //end of the main method

} //end of class

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote