Rewrite Listing 18.7, DirectorySize.java, without using recursion. Listing 1 import java.io.File; 2 import java.util.Scanner; 3 4 public
Question:
Rewrite Listing 18.7, DirectorySize.java, without using recursion.
Listing
Transcribed Image Text:
1 import java.io.File; 2 import java.util.Scanner; 3 4 public class DirectorySize { public static void main(String[] args) { 6 // Prompt the user to enter a directory or a file System.out.print("Enter a directory or a file: "); Scanner input - new Scanner (System.in); String directory = input.nextline(); 10 11 12 // Display the size System.out.printIn(getSize(new File(directory)) + " bytes"); 13
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 72% (11 reviews)
Output Program inputs the name of directory and outputs the size Compile javac Exercise2028ja...View the full answer
Answered By
Usman Nasir
I did Master of Commerce in year 2009 and completed ACCA (Association of Chartered Certified Accountants) in year 2013. I have 10 years of practical experience inclusive of teaching and industry. Currently i am working in a multinational company as finance manager and serving as part time teacher in a university. I have been doing tutoring via many sites. I am very strong at solving numerical / theoretical scenario-based questions.
4.60+
16+ Reviews
28+ Question Solved
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Question Posted:
Students also viewed these Computer science questions
-
Listing 20.7, DirectorySize.java, gives a recursive method for finding a directory size. Rewrite this method without using recursion. Your program should use a queue to store the subdirectories under...
-
The depth-first search algorithm described in Listing 28.8 uses recursion. Design a new algorithm without using recursion. Describe it using pseudocode. Implement it by defining a new class named...
-
Rewrite Programming Exercise 18.28 using a stack instead of a queue. DirectorySize.java, without using recursion. ? 1 import java.io.File; 2 import java.util.Scanner; 3 4 public class DirectorySize {...
-
From the information below, 1. List of the working capital accounts. 2. Calculate the net working capital. Buildings $100,000 Cash ... 5,000 Trade receivables ... 25,000 Trade and other payables .....
-
Using the natural order > on R, order the plane R2 by the lexicographic order. It is a total order?
-
Given M in Problems 3948, find M -1 and show that M -1 M = I. 1 2 3 1 0 0 -1 2
-
Determine the number of ideal stages required in Example 7.4 if the solvent rate used is twice the minimum. Data From Example 7.4:- A solution of acetic acid (C) in water (A) is to be extracted using...
-
Crop-Quick Inc. replenishes its three distribution centers in Boston, Denver and Houston from its Las Vegas central supply warehouse. The distribution schedule for one of its products for the next...
-
Bryson College is a highly politicized organization (Table 3.7). What changes in the organization of the college would be necessary for Bryson to become a professionalized organization? A...
-
Design a basic Expert System, which should include a Knowledge Base, Working Storage, User Interface, and an Inference Engine This system should have the capability to research products that are for...
-
Write a program that finds all occurrences of a word in all the files under a directory, recursively. Pass the parameters from the command line as follows: java Exercise18_30 dirName word
-
Write a program that will find a path in a maze, as shown in Figure 18.13a. The maze is represented by an 8 * 8 board. The path must meetthe following conditions:? The path is between the upper-left...
-
Morning Star Air, headquartered in Kunming, China, needs US$25,000,000 for one year to finance working capital. The airline has two alternatives for borrowing: Borrow US$25,000,000 in Eurodollars in...
-
How Have Advancements of Technology Aided Economic Progress in Developing Nations? Explain
-
What kinds of problems arise from the focus on standard GDP measures in discussing economic policy? Discuss briefly
-
2.1Given the following Matrices A and B, write the Octave commands and provide screenshots to show the following matrix operations: A X B, B - A, A+ B, and the inverse of matrix A. (Note: command...
-
Explain the historical definition of risk, loss exposure, and how objective risk differs from subjective risk. Define a chance of loss. What is the difference between objective probability and...
-
What are the three types of merger? For each type, define such, and give one reason or justification for that type of merger.
-
a) You deposit $800 into a savings account that pays 2.5% compounded annually. How much will you have in the account if you leave the money there for 6 years? b) You would like to have $30,000 in an...
-
Players A, B, and C toss a fair coin in order. The first to throw a head wins. What are their respective chances of winning?
-
Draw the AVL tree resulting from the removal of the entry with key 62 from the AVL tree of Figure 11.13b. 4 62 44 78) 50 88 48 54 T4 T2 (b)
-
Draw the AVL tree resulting from the insertion of an entry with key 52 into the AVL tree of Figure 11.13b. 4 62 44 78) 50 88 48 54 T4 T2 (b)
-
Consider the set of keys K = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}. a. Draw a (2,4) tree storing K as its keys using the fewest number of nodes. b. Draw a (2,4) tree storing K as its keys using the...
-
Do you look to social media to build your self-esteem? What aspects of social media make you feel better about yourself? What aspects make you feel worse? Do you think that social media has had an...
-
This is designed to help problem solvers speed up the slower process, slow other processes down to relieve pressure on the slow process, or a combination of the two. This statement BEST describes...
-
Write a routine request email to your supervisor asking for a 10% increase in your operating budget and to hire another team member for a new project your department is working on. The project is for...
Study smarter with the SolutionInn App