In Cpp
A rational number is a quotient of two integers.For example, 12/5,12/-4,-3/4, and 4/6 are all rational numbers .A rational number is said to be in reduced form if its denominator is positive and its numerator and denominator have no common divisor other than 1
For example,the reduced forms of the rational numbers given above are 12/5, -3/1, -3/4 and 2/3.
Write a class called Rational with a constructor Rational ( int, int) that takes two integers, a numerator and a denominator,and stores those two values in reduced form in corresponding private members.The class should have a private member function void reduce( ) that is used to accomplish the transformation to reduced form. The class should have an overloaded insertion operator << that will be used for output of objects of the class.
Part 2
Modify the class Rational of Programming Challenge 8 to add overloaded operators+,-,*,and/to be used for addition, subtraction,multiplication,and division.Test the class by reading and processing from the key board (or from a file) a series of rational expressions such as
2/3 + 2/8
2/3 * - 2/8
2/3 - 2/ 8
2/3 / 2/8
To facilitate parsing of the input, you may assume that numbers and arithmetic operators are separated by white space.
You should be turning in a Rational.h, Rational.cpp and rationaldriver.cpp that has your main.
All meaningful rational number code should be encapsulated in your Rational class.
Make sure to overload the asked for operators.
Make sure to create Rationals for each of the 4 stated examples in Rational Arithmetic I and show they reduce by using the overloaded << to output to the console.
Make sure to test your overloaded arithmetic expressions using the 4 expressions outlined in Rational Arithmetic II and output the resulting Rationals.
Use console for I/O. Use consts where appropriate.
In: Computer Science
Please include all inputs and outputs in details with pictures:
General rules: Create homework, compose specifications or any text by using a common document-creation tool, such as Microsoft® Word.
Detailed Hints: Refer to the wwweb or lecture notes for this class to design, implement, and debug solid SW solutions. Be concise, complete, and precise.
Abstract: Compute the performance data for the schedulers of three types of Operating Systems. Do not get scared! Only the timing for each scheduler is of interest. You can compute these timing data by hand or by actually implementing a simulator. Either solution is feasible and permitted. The simulator measures key performance data, such as throughput, wait time, and turn-around time. You may also manually compute these numbers without having to run them in a simulation environment.
If you chose to “manually” compute the data, i.e. without implementing a SW simulator, the amount of “generated performance data” is allowed to be way less detailed than what is suggested here.
One OS is a strict batch system with a non-preemptive First Come First Serve (FCFS) scheduler. The second OS uses a non-preemptive, high-priority first (HPF) scheduler, while the third OS uses a preemptive round robin (RR) scheduler with a variable time-quantum with varying context switch overhead. Design meaningful input data, run them through all schedulers, generate output data, and interpret and discuss the results. To start your simulations, use the sample data from this HW assignment. In addition, provide 2 additional, meaningful input scenarios, more complex than the samples given here.
Detail: HomeWork 1 consists of the following parts with equal weight each:
Input: Input to the schedulers is a list of processes, for which you happen to know the execution time in milliseconds. For your program input, each process is represented by a triple of decimal numbers id, time, priority. These multiple processes are scheduled and compete for the CPU resource. Here id is the name of the process; time is the time in milliseconds that process id needs to run to completion, and priority is the priority of process id. A plausible input sample for two processes with process id 1 and process id 4 is:
1 2 3
4 50 6
Depending on the scheduler, priority may be ignored. The meaning of triples is as follows:
1 2 3 process 1 uses 2 milliseconds to run, has priority 3
4 50 6 process 4 uses 50 milliseconds, has priority 6, with 0 being the highest
Use the definitions below to compute for each process Throughput, Wait Time, and Turn-around Time. Compute these for each of the 3 schedulers; also compute the average for all processes.
For the preemptive RR scheduler, vary the time quantum q from 1 to 5 milliseconds (ms). Also, for each q selected, vary the overhead o of a context switch from 0 ms up to q itself. There is no need to vary the o beyond q. When a process scheduled by the RR system has received all time needed to completion, do not add a final o unit in the computation of the total time for that process. Also the first time around, act as if the initial schedule overhead o is 0. Use the sample outputs below as a guide for the detail you should generate for this HW.
Definitions:
Throughput: Number of jobs (processes) completed per time unit
Waiting Time: The total time a process is in Ready Queue
Average Waiting Time: Average Waiting Time of n processes is: total waiting time by n
Turn-around Time: span of time of submission to completion time
Example 1:
Enter triples: process id, time in ms, and priority:
For example:
1 12 0
3 9 1
2 99 9
process 1 needs 12 ms and has priority 0, very high,
process 3 needs 9 ms and has priority 1.
and so on ...
1 2 3
2 1 2
Process list in FCFS order as entered:
1 2 3
2 1 2
End of list.
fcfs wait of p1 = 0
fcfs wait of p2 = 2
average wait for 2 procs = 1
fcfs turn-around time for p1 = 2
fcfs turn-around time for p2 = 3
average turn-around for 2 procs = 2.5
fcfs throughput for 2 procs = 0.666667 proc/ms
<><> end FCFS <><>
Process list in HPF order:
2 1 2
1 2 3
End of list.
hpf wait of p2 = 0
hpf wait of p1 = 1
average wait time for 2 procs = 0.5
hpf turn-around for p2 = 1
hpf turn-around for p1 = 3
average turn-around for 2 procs = 2
hpf throughput for 2 procs = 0.666667 proc/ms
<><> end HPF schedule <><>
Process list for RR in order entered:
1 2 3
2 1 2
End of list.
preemptive RR schedule, quantum = 1 overhead = 0
RR TA time for finished p2 = 2, needed: 1 ms, and: 1 time slices.
RR TA time for finished p1 = 3, needed: 2 ms, and: 2 time slices.
RR Throughput, 2 p, with q: 1, o: 0, is: 0.666667 p/ms, or 666.667 p/us
Average RR TA, 2 p, with q: 1, o: 0, is: 2.5
preemptive RR schedule, quantum = 1 overhead = 1
RR TA time for finished p2 = 3, needed: 1 ms, and: 1 time slices.
RR TA time for finished p1 = 5, needed: 2 ms, and: 2 time slices.
RR Throughput, 2 p, with q: 1, o: 1, is: 0.4 p/ms, or 400 p/us
Average RR TA, 2 p, with q: 1, o: 1, is: 4
preemptive RR schedule, quantum = 2 overhead = 0
RR TA time for finished p1 = 2, needed: 2 ms, and: 1 time slices.
RR TA time for finished p2 = 3, needed: 1 ms, and: 1 time slices.
RR Throughput, 2 p, with q: 2, o: 0, is: 0.666667 p/ms, or 666.667 p/us
Average RR TA, 2 p, with q: 2, o: 0, is: 2.5
preemptive RR schedule, quantum = 2 overhead = 1
RR TA time for finished p1 = 2, needed: 2 ms, and: 1 time slices.
RR TA time for finished p2 = 4, needed: 1 ms, and: 1 time slices.
RR Throughput, 2 p, with q: 2, o: 1, is: 0.5 p/ms, or 500 p/us
Average RR TA, 2 p, with q: 2, o: 1, is: 3
preemptive RR schedule, quantum = 2 overhead = 2
RR TA time for finished p1 = 2, needed: 2 ms, and: 1 time slices.
RR TA time for finished p2 = 5, needed: 1 ms, and: 1 time slices.
RR Throughput, 2 p, with q: 2, o: 2, is: 0.4 p/ms, or 400 p/us
Average RR TA, 2 p, with q: 2, o: 2, is: 3.5
<><> end preemptive RR schedule <><>
Example 2:
Enter triples: process id, time in ms, and priority:
For example:
1 12 0
3 9 1
2 99 9
process 1 needs 12 ms and has priority 0, very high,
process 3 needs 9 ms and has priority 1.
and so on ...
1 10 5
2 8 1
3 12 7
Process list in FCFS order as entered:
1 10 5
2 8 1
3 12 7
End of list.
fcfs wait of p1 = 0
fcfs wait of p2 = 10
fcfs wait of p3 = 18
average wait for 3 procs = 9.33333
fcfs turn-around time for p1 = 10
fcfs turn-around time for p2 = 18
fcfs turn-around time for p3 = 30
average turn-around for 3 procs = 19.3333
fcfs throughput for 3 procs = 0.1 proc/ms
<><> end FCFS <><>
Process list in HPF order:
2 8 1
1 10 5
3 12 7
End of list.
hpf wait of p2 = 0
hpf wait of p1 = 8
hpf wait of p3 = 18
average wait time for 3 procs = 8.66667
hpf turn-around for p2 = 8
hpf turn-around for p1 = 18
hpf turn-around for p3 = 30
average turn-around for 3 procs = 18.6667
hpf throughput for 3 procs = 0.1 proc/ms
<><> end HPF schedule <><>
Process list for RR in order entered:
1 10 5
2 8 1
3 12 7
End of list.
preemptive RR schedule, quantum = 1 overhead = 0
RR TA time for finished p2 = 23, needed: 8 ms, and: 8 time slices.
RR TA time for finished p1 = 27, needed: 10 ms, and: 10 time slices.
RR TA time for finished p3 = 30, needed: 12 ms, and: 12 time slices.
RR Throughput, 3 p, with q: 1, o: 0, is: 0.1 p/ms, or 100 p/us
Average RR TA, 3 p, with q: 1, o: 0, is: 26.6667
preemptive RR schedule, quantum = 1 overhead = 1
RR TA time for finished p2 = 45, needed: 8 ms, and: 8 time slices.
RR TA time for finished p1 = 53, needed: 10 ms, and: 10 time slices.
RR TA time for finished p3 = 59, needed: 12 ms, and: 12 time slices.
RR Throughput, 3 p, with q: 1, o: 1, is: 0.0508475 p/ms, or 50.8475 p/us
Average RR TA, 3 p, with q: 1, o: 1, is: 52.3333
preemptive RR schedule, quantum = 2 overhead = 0
RR TA time for finished p2 = 22, needed: 8 ms, and: 4 time slices.
RR TA time for finished p1 = 26, needed: 10 ms, and: 5 time slices.
RR TA time for finished p3 = 30, needed: 12 ms, and: 6 time slices.
RR Throughput, 3 p, with q: 2, o: 0, is: 0.1 p/ms, or 100 p/us
Average RR TA, 3 p, with q: 2, o: 0, is: 26
preemptive RR schedule, quantum = 2 overhead = 1
RR TA time for finished p2 = 32, needed: 8 ms, and: 4 time slices.
RR TA time for finished p1 = 38, needed: 10 ms, and: 5 time slices.
RR TA time for finished p3 = 44, needed: 12 ms, and: 6 time slices.
RR Throughput, 3 p, with q: 2, o: 1, is: 0.0681818 p/ms, or 68.1818 p/us
Average RR TA, 3 p, with q: 2, o: 1, is: 38
preemptive RR schedule, quantum = 2 overhead = 2
RR TA time for finished p2 = 42, needed: 8 ms, and: 4 time slices.
RR TA time for finished p1 = 50, needed: 10 ms, and: 5 time slices.
RR TA time for finished p3 = 58, needed: 12 ms, and: 6 time slices.
RR Throughput, 3 p, with q: 2, o: 2, is: 0.0517241 p/ms, or 51.7241 p/us
Average RR TA, 3 p, with q: 2, o: 2, is: 50
preemptive RR schedule, quantum = 3 overhead = 0
RR TA time for finished p2 = 23, needed: 8 ms, and: 3 time slices.
RR TA time for finished p1 = 27, needed: 10 ms, and: 4 time slices.
RR TA time for finished p3 = 30, needed: 12 ms, and: 4 time slices.
RR Throughput, 3 p, with q: 3, o: 0, is: 0.1 p/ms, or 100 p/us
Average RR TA, 3 p, with q: 3, o: 0, is: 26.6667
preemptive RR schedule, quantum = 3 overhead = 1
RR TA time for finished p2 = 30, needed: 8 ms, and: 3 time slices.
RR TA time for finished p1 = 36, needed: 10 ms, and: 4 time slices.
RR TA time for finished p3 = 40, needed: 12 ms, and: 4 time slices.
RR Throughput, 3 p, with q: 3, o: 1, is: 0.075 p/ms, or 75 p/us
Average RR TA, 3 p, with q: 3, o: 1, is: 35.3333
preemptive RR schedule, quantum = 4 overhead = 0
RR TA time for finished p2 = 20, needed: 8 ms, and: 2 time slices.
RR TA time for finished p1 = 26, needed: 10 ms, and: 3 time slices.
RR TA time for finished p3 = 30, needed: 12 ms, and: 3 time slices.
RR Throughput, 3 p, with q: 4, o: 0, is: 0.1 p/ms, or 100 p/us
Average RR TA, 3 p, with q: 4, o: 0, is: 25.3333
preemptive RR schedule, quantum = 5 overhead = 0
RR TA time for finished p1 = 20, needed: 10 ms, and: 2 time slices.
RR TA time for finished p2 = 23, needed: 8 ms, and: 2 time slices.
RR TA time for finished p3 = 30, needed: 12 ms, and: 3 time slices.
RR Throughput, 3 p, with q: 5, o: 0, is: 0.1 p/ms, or 100 p/us
Average RR TA, 3 p, with q: 5, o: 0, is: 24.3333
some outputs I have to cut because Chegg say the question is long
In: Computer Science
Explain the effects to Neurons specifically in each of the following diseases…think generalized 1 sentence answers
1) Multiple Sclerosis
2) ALS-Amyotrophic Lateral Sclerosis
3) Parkinson's Disease
4) Alzheimer's Disease
In: Anatomy and Physiology
Problem: Perform following operations in binary using 8-bit
addition/subtraction/multiplication.
1. −80 + 42
2. −99 − 20
3. 60 − 70
4. −59 × 3
5. 52×−1
In: Computer Science
In C++, write a function to fill an array of size 13 with values
13 11 9 7 5 3 1 2 4 6 8 10 12
recursively, starting with the value 1 in the middle.
In: Computer Science
|
Winter Company, a manufacturer of leather bags had the following
budgeted information for October 2019:
Calculate the following:
|
In: Accounting
1.Find the present value at time 0 of $15086 due at the end of 4.88 years if the force of interest δ=0.023δ=0.023.
2.If an investment will double in 8.15 years at a constant force of interest δ, then
3.An investment of $1300 at t = 0 accumulates at a constant force of interest δδ= 4% for the first 4 years and at a nominal annual rate of interest of 5% compounded semiannually thereafter. Find the accumulated value of this investment at time t = 11.
4.An investment pays $1150 at time 0 and $2250 at the end of 3 years. Find the accumulated value of this investment at time 8 if the force of interest δt=0.02(1+t)2δt=0.02(1+t)2.
5.An investment of $1700 at t = 4 accumulates at a force of interest δt=0.003+0.009t2δt=0.003+0.009t2. Find the accumulated value of this investment at time t = 9.
6.How long does it take an amount to triple if the force of interest δ=0.062δ=0.062.
In: Advanced Math
•VOOM HAS FOUR WAREHOUSES 1, 2,3, AND 4. VOOM NEEDS TO SUPPLY 100 TONS TO RETAILER P, 300 TONS TO RETAILER Q, AND 300 TONS TO RETAILER R. THE COST OF DELIVERY FROM EACH WAREHOUSE TO RETAILERS IS PROVIDED IN THE FOLLOWING TABLE. WHILE EACH OF THE WAREHOUSES HAS AN INVENTORY OF 400 TONS THEY CAN SUPPLY, R REQUIRES THAT EVERY WAREHOUSE SUPPLIES AT LEAST 25 TONS TO R.
THERE IS A SPECIAL ARRANGEMENT BETWEEN WAREHOUSE 4 AND R WHICH REQUIRES THAT WAREHOUSE 4 HAS TO SUPPLY EXACTLY 100 TONS TO R. ON THE OTHER HAND, P CANNOT TAKE MORE THAN 50 TONS EACH FROM WAREHOUSE 1 AND 2.
•
•USE LINEAR PROGRAMMING TO PROVIDE VOOM A PLAN THAT WILL KEEP THEIR TRANSPORTATION COST TO THE MINIMUM.
|
Delivery cost/ton($) |
P |
Q |
R |
|
Warehouse 1 |
$ 14.00 |
$ 30.00 |
$ 20.00 |
|
Warehouse 2 |
$ 30.00 |
$ 40.00 |
$ 15.00 |
|
Warehouse 3 |
$ 18.00 |
$ 20.00 |
$ 14.00 |
|
Warehouse 4 |
$ 15.50 |
$ 12.00 |
$ 18.00 |
Please show on excel and steps
In: Operations Management
From the following? information, calculate the cost of ending inventory and cost of goods sold using the? (a) FIFO,? (b) LIFO, and? (c) weighted-average methods.
|
Units |
Cost |
||
|
January 1 |
Beginning Inventory |
4 |
$7 |
|
March 6 |
Purchased |
6 |
2 |
|
August 9 |
Purchased |
4 |
9 |
|
December 10 |
Purchased |
5 |
1 |
The ending inventory reveals eighteight items unsold
In: Accounting
What is the net present value of a project that has an initial cash outflow of $-13,000, at time 0, and the following cash flows for years 1-4? The required return is 10.0%. DO NOT USE DOLLAR SIGNS OR COMMAS IN YOUR ANSWER. ENTER YOUR ANSWER TO THE NEAREST DOLLAR (e.g. 1250). Year Cash Flows 1 $3,950 2 $3,750 3 $5,900 4 $6,400
In: Finance