C++ for Engineers and Scientists
C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
expand_more
expand_more
format_list_bulleted
Bartleby Related Questions Icon
Related questions
Question
Transcribed Image Text:A3Q3.c - You are to write a C program that implements the following disk scheduling
algorithms:
a. FCFS [10 marks]
b. SCAN [10 marks]
c. C-SCAN [10 marks]
d. SSTF [10 marks]
e. LOOK [10 marks]
f. C-LOOK [10 marks]
•
Your program will service a disk with 300 cylinders numbered 0 to 299.
•
•
•
•
The program will service the requests (a list of 20 cylinder numbers) given in the file
request.bin.
This file contains (4 byte) integer values representing requests ranging from 0-299.
Your program will take the initial position of the disk head as the first command line
argument and the direction of the head as the second command line argument.
It will then output the requests in the order in which they are serviced, and the total
amount of head movements required by each algorithm.
In particular, your program needs to do the following:
Your program should take two command line arguments
a) First command line argument - initial position of the disk head (an integer value)
b) Second command line argument - direction of the head (LEFT or RIGHT)
2) Read the requests from the binary file (requests.bin), and store these requests in
an integer array (for example: requests), after which you need to close the file.
3) Write functions for each disk scheduling algorithm.
4) The scheduling algorithms will service requests present in the requests array.
5) Since the requests are serviced in an order by the scheduling algorithms, you may
need to first sort the requests in the requests array in an increasing order and
store the sorted requests in another integer array (for example: sortedrequests).
These algorithms will then service the requests in the sortedrequests array and
compute the head movements.
6) You can use any sorting algorithm of your choice. You should simply analysis
whether your sorting algorithm is efficient or not.
7) Your program should output the following (see sample output given below):
a) Requests in the order in which they are serviced by each algorithm.
b) Total amount of head movement incurred by each algorithm while servicing all
the requests.
Expert Solution
Check MarkThis question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
bartleby
Step by stepSolved in 2 steps with 3 images
Knowledge Booster
Background pattern image
Similar questions
- Task - Assembly - A first programThe first task is to actually just write a 'hello world' in assembly.• Enter the following text into a file called hello.s• # Example for x86-64 processor using AT&T Style syntax• .global _start• • .text• • _start:• # Write a message to the screen• mov 1,ドル %rax• mov 1,ドル %rdi• mov $message, %rsi• mov 13,ドル %rdx• syscall• • # Exit the program• mov 60,ドル %rax• xor %rdi, %rdi• syscall• • message:• .ascii "Hello, World\n"arrow_forwardPlease write this in c++ !!arrow_forward1. Consider the following incomplete C++ program: #include int main() { ... } a. Write a statement that includes the header files fstream, string, and iomanip in this program. b. Write statements that declare inFile to be an ifstream variable and outFile to be an ofstream variable. c. The program will read data from the file inData.txt and write output to the file outData.txt. Write statements to open both of these files, associate inFile with inData.txt, and associate outFile with outData.txt. d. Suppose that the file inData.txt contains the following data: Giselle Robinson Accounting 5600 5 30 450 9 75 1.5 The first line contains a person's first name, last name, and the department the person works in. In the second line, the first number represents the monthly gross salary, the bonus (as a percent), and the taxes (as a percent). The third line contains the distance traveled and the traveling time. The fourth line contains the number of coffee cups sold and the cost of each coffee cup. Write statements so that after the program executes, the contents of the file outData.txt are as shown below. If necessary, declare additional variables. Your statements should be general enough so that if the content of the input file changes and the program is run again (without editing and recompiling), it outputs the appropriate results. Name: Giselle Robinson, Department: Accounting Monthly Gross Salary: 5600ドル.00, Monthly Bonus: 5.00, Taxes: 30.000 Paycheck: 4116ドル.00 Distance Traveled 450.00 miles, Traveling Time: 9.00 hours Average Speed: 50.00 miles per hour Number of coffee Cups Sold: 75, Cost: 1ドル.50 per cup Sales Amount = 112ドル.50 e. Write statements that close the input and output files. f. Write a C++ program that tests the statements in parts a through e.arrow_forward
- Mark the following statements as true or false. An output stream is a sequence of characters from a computer to an output device. (1) To use cin and cout in a program, the program must include the header file iostream. (1, 2) Suppose pay is a variable of type double. The statement cin pay, requires the input of a decimal number. (2) The statement cin length; and length cin; are equivalent. (2) When the statement cin numl num2; executes, then after inputting a number into the variable numl the program skips all trailing whitespace characters. (2) To use the predefined function sqrt in a program, the program must include the header file cmath. (3) The statement cin.get (ch); inputs the next nonwhitespace character into the variable ch. (4) When the input stream enters the fail state, the program terminates with an error message. (5) To use the manipulators fixed and showpoint, the program does not require the inclusion of the header file iomanip. (6) The statement cin right; sets the input of only the next variable right-justified. (7) To input data from a file, the program must include the header file fstream. (10)arrow_forwardHow is an array stored in main memory? How is a linked list stored in main memory? What are their comparative advantages and disadvantages? Give examples of data that would be best stored as an array and as a linked list.arrow_forward(Data processing) a. Write a C++ program that opens a file and displays its contents with line numbers. That is, the program should print the number 1 before displaying the first line, print the number 2 before displaying the second line, and so on for each line in the file. b. Modify the program written in Exercise 6a to list the file’s contents on the printer assigned to your computer.arrow_forward
- (Data processing) Write a C++ program that reads the file created in Exercise 4, permits the user to change the hourly wage or years for any employee, and creates a new updated file.arrow_forward(Data processing) Write a C++ program that allows the user to enter the following information from the keyboard for each student in a class (up to 20 students): Name Exam 1 Grade Exam 2 Grade Homework Grade Final Exam Grade For each student, your program should first calculate a final grade, using this formula: FinalGrade=0.20Exam1+0.20Exam2+0.35Homework+0.25FinalExam Then assign a letter grade on the basis of 90100=A,8089=B,7079=C,6069=D, and less than 60=F . All the information, including the final grade and the letter grade, should then be displayed and written to a file.arrow_forward(Data processing) Write a C++ program that reads the file created in Exercise 4 one record at a time, asks for the number of hours each employee worked each month, and calculates and displays each employee’s total pay for the month.arrow_forward
- (Data processing) A bank’s customer records are to be stored in a file and read into a set of arrays so that a customer’s record can be accessed randomly by account number. Create the file by entering five customer records, with each record consisting of an integer account number (starting with account number 1000), a first name (maximum of 10 characters), a last name (maximum of 15 characters), and a double-precision number for the account balance. After the file is created, write a C++ program that requests a user-input account number and displays the corresponding name and account balance from the file.arrow_forwardCreate a program named FileComparison that compares two files. First, use a text editor such as Notepad to save your favorite movie quote. Next, copy the file contents, and paste them into a word-processing program such as Word. Then, write the file-comparison application that displays the sizes of the two files as well as the ratio of their sizes to each other. To discover a files size, you can create a System. 10. Filelnfo object using statements such as the following, where FILE_NAME is a string that contains the name of the file, and size has been declared as an integer: FileInfo fileInfo = new FileInfo(FILE_NAME); size = fileInfo.Length;arrow_forward(Data processing) Your professor has asked you to write a C++ program that determines grades at the end of the semester. For each student, identified by an integer number between 1 and 60, four exam grades must be kept, and two final grade averages must be computed. The first grade average is simply the average of all four grades. The second grade average is computed by weighting the four grades as follows: The first grade gets a weight of 0.2, the second grade gets a weight of 0.3, the third grade gets a weight of 0.3, and the fourth grade gets a weight of 0.2. That is, the final grade is computed as follows: 0.2grade1+0.3grade2+0.3grade3+0.2grade4 Using this information, construct a 60-by-7 two-dimensional array, in which the first column is used for the student number, the next four columns for the grades, and the last two columns for the computed final grades. The program’s output should be a display of the data in the completed array. For testing purposes, the professor has provided the following data:arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Text book imageC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrText book imageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTText book imageC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
- Text book imageProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageText book imageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Text book imageSystems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning