(a) Write C++ statements to do the following: i. ii. iii. iv. V. vi. Declare an...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
(a) Write C++ statements to do the following: i. ii. iii. iv. V. vi. Declare an object to read data from a file; Use this object to open a file named x. dat; Read input from x.dat and store it in the previously declared variable x; Declare an object to write data to a file; Use this object to open a file named sqrtx.dat; Calculate the square root of the value of x and output the result to sqrtx.dat. (6 marks) (b) Using the statements from part (a) above, write a C++ program that reads in a list of values for the variable x from x.dat and calculates √x, writing the output to sqrtx.dat. Use an appropriate loop, assume x.dat has 100 lines and, if x is negative, set √x = 0. Include the appropriate header files in your program. (13 marks) (a) Write C++ statements to do the following: i. ii. iii. iv. V. vi. Declare an object to read data from a file; Use this object to open a file named x. dat; Read input from x.dat and store it in the previously declared variable x; Declare an object to write data to a file; Use this object to open a file named sqrtx.dat; Calculate the square root of the value of x and output the result to sqrtx.dat. (6 marks) (b) Using the statements from part (a) above, write a C++ program that reads in a list of values for the variable x from x.dat and calculates √x, writing the output to sqrtx.dat. Use an appropriate loop, assume x.dat has 100 lines and, if x is negative, set √x = 0. Include the appropriate header files in your program. (13 marks)
Expert Answer:
Answer rating: 100% (QA)
include include include int main Part a i Declare an object to read data from a file stdifstream inp... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
What portion of the company's (Crocs) assets and sales has been attributed to a different line of businesses in each of the past five years ( 2018-2022) ? (For public companies, this information may...
-
Two medical supply companies in San Francisco provided oxygen to patients at home. The companies were owned by the doctors who prescribed the oxygen. These doctors made up 60 percent of the lung...
-
In 20X2, Jacque's Gardening Supply acquired Glenn's Agricultural Center and recorded goodwill in the amount of $450,000. At the end of the 20X4 year, the net assets (including goodwill) of Glenn's...
-
Graph the solution of each system given in Problems 5-18. \(\left\{\begin{array}{l}x \geq 0 \\ y \geq 0 \\ x <500 \\ y \leq 1,000\end{array}ight.\)
-
Refer to Exercise 11.66 and find an 80% confidence interval for the ratio of the population standard deviations of CSBS scores for stutterers and nonstutterers in the age group under consideration....
-
Perform the operation and write the result in standard form. 1. (1 + i) (3 2i) 2. (7 2i) (3 5i) 3. 12i(1 9i)
-
For the dissolution of platelets in dilute solution with independent dissolution mass transfer coefficients for the flat and growth sides, a. Show that \[ \begin{aligned} & h=-2 k_{\text {flat }}...
-
Rob Judson Company had the following transactions involving notes payable. July 1, 2010 Borrows $50,000 from Third National Bank by signing a 9-month, 12% note. Nov. 1, 2010 Borrows $60,000 from...
-
23 Calculate the price of a bond with FV of $1,000, a coupon rate of 14 percent (paid semi-annually), and 4 years to maturity when A. kb = 16 percent B. kb = 14 percent C. kb = 12 percent (Round...
-
The Heartland Distribution Company is a food warehouse and distributor that has a contract with a grocery store chain in several Midwest and Southeast cities. The company wants to construct new...
-
1. A certain small country has $56 billion in paper currency in circulation, and each day $152 million comes into the country's banks. The government decides to introduce new currency by having the...
-
Posey's Pet Emporium Sales Forecast July August September Quarter Budgeted sales volume $32,000.00 $35,200.00 $35,000.00 $102,200.00 Budgeted selling price $4.99 $4.99 $4.99 $4.99 Budgeted sales...
-
The Adams family includes a financially well-informed couple, both aged 36, and two children aged 4 and 6. The family is financially sound but suffered badly during the tech meltdown in 2000. The...
-
In a study that was published 2021 by the National Institutes of Health and a podcast by Onword Radio, the researchers and hosts came to the conclusion that African Americans have a higher risk than...
-
Adjustments Debit Credit Prepaid Rent (A) 1,700 Office Supplies (B) 300 Accumulated Depreciation, Equipment (C) 375 Salaries Payable (D) 1,000 Rent Expense (A) 1,700 Office Supplies Expense (B) 300...
-
Develop a 3-year financial projection for your proposed cancer tele-genetics program . State any and all assumptions you make in creating your estimates. Please consider the following in creating...
-
On July 1, 2020, United Flag Company took out a 15-year loan for $144,000. Principal repayments of $9,600 and interest at 8% are due annually on June 30. Prepare all of the journal entries required...
-
What steps must a business take to implement a program of social responsibility?
-
Consider the reaction: If a mixture of solid nickel(II) oxide and 0.20 M carbon monoxide comes to equilibrium at 1500 K, what is the equilibrium concentration of CO 2 ? NiO(s) + CO(g) Ni(s) + CO(g) K...
-
An LP gas tank in a home barbeque contains 13.2 kg of propane, C 3 H 8 . Calculate the heat (in kJ) associated with the complete combustion of all of the propane in the tank. C3Hg(g) + 5 O2(g) 3...
-
A laser pulse with wavelength 532 nm contains 3.85 mJ of energy. How many photons are in the laser pulse?
-
The average total cost curve rises at high levels of output because of _________ product.
-
When AVC is falling, MC must be _________ than AVC; and when AVC is rising, MC must be _________ than AVC.
-
In the _________ run, a company cannot vary its plant size and equipment, so the firm can only expand output by employing more _________ inputs.
Study smarter with the SolutionInn App