
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 (7th Edition)
- using r language Obtain a bootstrap t confidence interval estimate for the correlation statistic in Example 8.2 (law data in bootstrap).arrow_forwardusing r language Compute a jackknife estimate of the bias and the standard error of the correlation statistic in Example 8.2.arrow_forwardusing r languagearrow_forward
- using r languagearrow_forwardThe assignment here is to write an app using a database named CIT321 with a collection named students; we will provide a CSV file of the data. You need to use Vue.js to display 2 pages. You should know that this assignment is similar, all too similar in fact, to the cars4sale2 example in the lecture notes for Vue.js 2. You should study that program first. If you figure out cars4sale2, then program 6 will be extremely straightforward. It is not my intent do drop a ton of new material here in the last few days of class. The database contains 51 documents. The first rows of the CSV file look like this: sid last_name 1 Astaire first_name Humphrey CIT major hrs_attempted gpa_points 10 34 2 Bacall Katharine EET 40 128 3 Bergman Bette EET 42 97 4 Bogart Cary CIT 11 33 5 Brando James WEB 59 183 6 Cagney Marlon CIT 13 40 GPA is calculated as gpa_points divided by hrs_attempted. GPA points would have been arrived at by adding 4 points for each credit hour of A, 3 points for each credit hour of…arrow_forwardI need help to solve the following case, thank youarrow_forward
- You will write a program that allows the user to keep track of college locations and details about each location. To begin you will create a College python class that keeps track of the csollege's unique id number, name, address, phone number, maximum students, and average tuition cost. Once you have built the College class, you will write a program that stores College objects in a dictionary while using the College's unique id number as the key. The program should display a menu in this order that lets the user: 1) Add a new College 2) Look up a College 4) Delete an existing College 5) Change an existing College's name, address, phone number, maximum guests, and average tuition cost. 6) Exit the programarrow_forwardShow all the workarrow_forwardConstruct a frequency polygon density estimate for the sample in Question 1, using bin width determined by Sturges’ Rule.arrow_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




