
Explanation of Solution
Step 1: First get the number of free block and store it in a variable “blocks”.
Step 2: Assign “true” to a Boolean variable “flag”.
Step 3: WHILE “flag”.
Step 4: Get the size of the file in bytes and store it in a variable “size”.
Step 5: Calculate the compressed size of the file and store it in a variable “compress”.
Step 6: Calculate number of blocks required for the file and store it in a variable “blocksNeeded”. This is done by dividing “compress” by 512.
Step 7: Check if the “blocksNeeded” is less than “blocks”.
Step 8: If the condition is true then reduce the number of free blocks. This is done by subtracting “blocksNeeded” from “blocks”.
Step 9: If the condition is false then assign “false” to the variable “flag”.
Complete program:
//Import required packages
import static java.lang.Math.round;
import java.util.*;
//Define the main class
public class FileSize
{
//Define the main method
public static void main(String[] args)
{
//Declare required variables
double blocks, size;
boolean flag = true;
//Create an object for scanner class
Scanner sc = new Scanner(System.in);
//Get the number of free blocks
System.out.print("Enter the number of free blocks: ");
blocks = sc.nextInt();
//While true
while(flag)
{
//Declare required variables
double compress = 0, blocksNeeded = 0;
//Get the size of the file
System.out.print("\nEnter the size of file in bytes: ");
size = sc...

Want to see the full answer?
Check out a sample textbook solution
Chapter 4 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
- Answer this JAVA OOP question below: An Employee has a name, employee ID, and department. An Employee object must be created with all its attributes. The UML diagram is provided below: - name: String - employeeId: String - department: String + Employee(name: String, employeeId: String, department: String) + setName(name: String): void + setEmployeeId(employeeId: String): void + setDepartment(department: String): void + getName(): String + getEmployeeId(): String + getDepartment(): String + toString(): String A faculty is an Employee with an additional field String field: rank public class TestImplementation{ public static void main(String[] args){ Employee[] allEmployee = new Employee[100]; // create an employee object with name Tom Evan, employee ID 001 and department IST and store it in allEmployee // create a faculty object with name Adam Scott, employee ID 002, department IST and rank Professor and store it in allEmployee } }arrow_forwardPlease answer this JAVA OOP question that is given below: An Employee has a name, employee ID, and department. An Employee object must be created with all its attributes. The UML diagram is provided below: - name: String - employeeId: String - department: String + Employee(name: String, employeeId: String, department: String) + setName(name: String): void + setEmployeeId(employeeId: String): void + setDepartment(department: String): void + getName(): String + getEmployeeId(): String + getDepartment(): String + toString(): String A faculty is an Employee with an additional field String field: rank Assuming the Employee class is fully implemented, define a Professor class in Java with the following: A toString() method that includes both the inherited attributes and the specializationarrow_forwardPlease answer JAVA OOP question below: An Employee has a name, employee ID, and department. An Employee object must be created with all its attributes. The UML diagram is provided below: - name: String - employeeId: String - department: String + Employee(name: String, employeeId: String, department: String) + setName(name: String): void + setEmployeeId(employeeId: String): void + setDepartment(department: String): void + getName(): String + getEmployeeId(): String + getDepartment(): String + toString(): String A faculty is an Employee with an additional field String field: rank Assuming the Employee class is fully implemented, define a Professor class in Java with the following: Instance variable(s) A Constructorarrow_forward
- Develop a C++ program that execute the operation as stated by TM for addition of two binary numbers (see attached image). Your code should receive two binary numbers and output the resulting sum (also in binary). Make sure your code mimics the TM operations (dealing with the binary numbers as a string of characters 1 and 0, and following the logic to increase the first number and decreasing the second one. Try your TM for the following examples: 1101 and 101, resulting 10010; and 1101 and 11, resulting 10000.arrow_forwardI need to define and discuss the uses of one monitoring or troubleshooting tool in Windows Server 2019. thank youarrow_forwardI would likr toget help with the following concepts: - Windows Server features - Windows Server versus Windows 10 used as a client-server networkarrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning




