Working with Files in C++.
Create the following program called payroll.cpp. Note that the file you read must be created before you run this program. The output file will be created automatically by the program. You can save the input file in the same directory as your payroll.cpp file by using Add New Item, Text File.
// File: Payroll.cpp
// Purpose: Read data from a file and write out a payroll
// Programmer: (your name and section)
#include <cstdlib> // for the definition of EXIT_FAILURE
#include <fstream> // required for external file streams
#include <iostream> // required for cin cout
using namespace std;
int main ()
{
ifstream ins; // associates ins as an input stream
ofstream outs; // associates outs as an output stream
int id; // id for employee
double hours, rate; // hours and rate worked
double pay; // pay calculated
double total_pay; // grand total of pay
// Open input and output file, exit on any error
ins.open ("em_in.txt"); // ins connects to file "em_in.txt"
if (ins.fail ())
{
cout << "*** ERROR: Cannot open input file. " << endl;
getchar(); // hold the screen
return EXIT_FAILURE;
} // end if
outs.open ("em_out.txt"); // outs connects to file "em_out.txt"
if (outs.fail ())
{
cout << "*** ERROR: Cannot open output file." << endl;
getchar();
return EXIT_FAILURE;
} // end if
// Set total_pay to 0
total_pay = 0;
ins >> id; // get first id from file
// Do the payroll while the id number is not the sentinel value
while (id != 0)
{
ins >> hours >> rate;
pay = hours * rate;
total_pay += pay;
outs << "For employee " << id << endl;
outs << "The pay is " << pay << " for " << hours
<< " hours worked at " << rate << " rate of pay" << endl << endl;
ins >> id;
} // end while
// Display a message on the screen
cout << "Employee processing finished" << endl;
cout << "Grand total paid out is " << total_pay << endl;
ins.close(); // close input file stream
outs.close(); // close output file stream
return 0;
}
Create the input file:
Inside C++ go to File Add New Item and then Text to create a text file.
Type in the data below
In the same directory as your .cpp file for Payroll.cpp click Files and Save As em_in.txt
1234
35 10.5
3456
40 20.5
0
solution should show :
-the output file
-the input file
-the screen output
-the source program
In: Computer Science
Walmart, America’s largest retailer had the market’s second largest debt issuance in the U.S. in 2019, selling $16 billion in 30 year bonds. The funds were to help finance the purchase of Flipkart, India’s largest online seller. Thanks to Walmart’s high credit rating, the bonds were classified by Moody’s (one of the top bond rating agencies) as Aa2, or very highly rated. The bond sale was managed by a syndicate of investment banks, including Barclays Plc, Citigroup Inc., JPMorgan Chase & Co., Bank of America Corp., HSBC Holdings Plc and Wells Fargo & Co.
Data for Walmart as of April 2019
|
Market Price |
$103.18 |
|
# Shares (mm, or millions) |
2,897 |
|
Long term debt ($mm from balance sheet) |
$45,396 |
|
Tax rate (T) |
25% |
|
Walmart beta (β) |
0.66 |
|
Current risk free rate (rf) |
2.59% |
|
Estimated market risk premium |
6.00% |
|
Estimated underwriter spread |
1.0% |
|
Estimated additional flotation costs |
0.5% |
|
Estimated total flotation cost (as a % of debt face value) |
1.50% |
|
WalMart data to use |
2015 |
2016 |
2017 |
2018 |
2019 |
|
Dividend payout ratio (dividends paid out as a % of net income) |
38.02% |
42.89% |
45.59% |
62.04% |
91.68% |
|
Net income ($ millions) |
$16363 |
$14694 |
$13643 |
$9862 |
6670 |
|
Common equity $ (millions, book value) |
$85937 |
$83611 |
$80535 |
$80822 |
79634 |
|
ROE (net income/common equity or NI/CE) |
19.04% |
17.57% |
16.94% |
12.20% |
8.38% |
|
2015 |
2016 |
2017 |
2018 |
2019 |
|
|
Dividend history ($/share) |
$1.91 |
$1.96 |
$2.00 |
$2.04 |
$2.08 |
|
2020 |
2021 |
2022 |
2023 |
||
|
Dividend estimates ($/share) |
$2.14 |
$2.05 |
$2.40 |
$2.48 |
Basic “starting point” data:
You are to calculate each of the following based on the data provided above.
|
1) |
Value of equity (market capitalization) |
298912.46 |
|
2) |
Value of long term debt (use book value as given) |
$45,396 |
|
3) |
Weight of equity |
0.868 |
|
4) |
Weight of debt |
0.132 |
Need help with the questions below based on the information above:
5. What is the 3 year growth rate (2020-2023) of expected dividends?
In: Finance
| Sale Price | List Price | Days to Sell | Gulf View |
| 475 | 495 | 130 | 1 |
| 350 | 379 | 71 | 1 |
| 519 | 529 | 85 | 1 |
| 534.5 | 552.5 | 95 | 1 |
| 334.9 | 334.9 | 119 | 1 |
| 505 | 550 | 92 | 1 |
| 165 | 169.9 | 197 | 1 |
| 210 | 210 | 56 | 1 |
| 945 | 975 | 73 | 1 |
| 314 | 314 | 126 | 1 |
| 305 | 315 | 88 | 1 |
| 800 | 885 | 282 | 1 |
| 975 | 975 | 100 | 1 |
| 445 | 469 | 56 | 1 |
| 305 | 329 | 49 | 1 |
| 330 | 365 | 48 | 1 |
| 312 | 332 | 88 | 1 |
| 495 | 520 | 161 | 1 |
| 405 | 425 | 149 | 1 |
| 669 | 675 | 142 | 1 |
| 400 | 409 | 28 | 1 |
| 649 | 649 | 29 | 1 |
| 305 | 319 | 140 | 1 |
| 410 | 425 | 85 | 1 |
| 340 | 359 | 107 | 1 |
| 449 | 469 | 72 | 1 |
| 875 | 895 | 129 | 1 |
| 430 | 439 | 160 | 1 |
| 400 | 435 | 206 | 1 |
| 227 | 235 | 91 | 1 |
| 618 | 638 | 100 | 1 |
| 600 | 629 | 97 | 1 |
| 309 | 329 | 114 | 1 |
| 555 | 595 | 45 | 1 |
| 315 | 339 | 150 | 1 |
| 200 | 215 | 48 | 1 |
| 375 | 395 | 135 | 1 |
| 425 | 449 | 53 | 1 |
| 465 | 499 | 86 | 1 |
| 428.5 | 439 | 158 | 1 |
| 217 | 217 | 182 | 0 |
| 135.5 | 148 | 338 | 0 |
| 179 | 186.5 | 122 | 0 |
| 230 | 239 | 150 | 0 |
| 267.5 | 279 | 169 | 0 |
| 214 | 215 | 58 | 0 |
| 259 | 279 | 110 | 0 |
| 176.5 | 179.9 | 130 | 0 |
| 144.9 | 149.9 | 149 | 0 |
| 230 | 235 | 114 | 0 |
| 192 | 199.8 | 120 | 0 |
| 195 | 210 | 61 | 0 |
| 212 | 226 | 146 | 0 |
| 146.5 | 149.9 | 137 | 0 |
| 160 | 160 | 281 | 0 |
| 292.5 | 322 | 63 | 0 |
| 179 | 187.5 | 48 | 0 |
| 227 | 247 | 52 | 0 |
Use descriptive statistics to summarize each of the three variables for the 40 Gulf View condos. Describe the distribution of each variable. Repeat for the 18 No Gulf View Condos. (This includes the five-number summary, the mean, standard deviation, and a histogram of each variable). Gulf View condos are denoted by “1” in the Gulf View column, whereas No Gulf View condos are denoted by “0”. Prices are in thousands of dollars.
In: Statistics and Probability
| Sale Price | List Price | Days to Sell | Gulf View |
| 475 | 495 | 130 | 1 |
| 350 | 379 | 71 | 1 |
| 519 | 529 | 85 | 1 |
| 534.5 | 552.5 | 95 | 1 |
| 334.9 | 334.9 | 119 | 1 |
| 505 | 550 | 92 | 1 |
| 165 | 169.9 | 197 | 1 |
| 210 | 210 | 56 | 1 |
| 945 | 975 | 73 | 1 |
| 314 | 314 | 126 | 1 |
| 305 | 315 | 88 | 1 |
| 800 | 885 | 282 | 1 |
| 975 | 975 | 100 | 1 |
| 445 | 469 | 56 | 1 |
| 305 | 329 | 49 | 1 |
| 330 | 365 | 48 | 1 |
| 312 | 332 | 88 | 1 |
| 495 | 520 | 161 | 1 |
| 405 | 425 | 149 | 1 |
| 669 | 675 | 142 | 1 |
| 400 | 409 | 28 | 1 |
| 649 | 649 | 29 | 1 |
| 305 | 319 | 140 | 1 |
| 410 | 425 | 85 | 1 |
| 340 | 359 | 107 | 1 |
| 449 | 469 | 72 | 1 |
| 875 | 895 | 129 | 1 |
| 430 | 439 | 160 | 1 |
| 400 | 435 | 206 | 1 |
| 227 | 235 | 91 | 1 |
| 618 | 638 | 100 | 1 |
| 600 | 629 | 97 | 1 |
| 309 | 329 | 114 | 1 |
| 555 | 595 | 45 | 1 |
| 315 | 339 | 150 | 1 |
| 200 | 215 | 48 | 1 |
| 375 | 395 | 135 | 1 |
| 425 | 449 | 53 | 1 |
| 465 | 499 | 86 | 1 |
| 428.5 | 439 | 158 | 1 |
| 217 | 217 | 182 | 0 |
| 135.5 | 148 | 338 | 0 |
| 179 | 186.5 | 122 | 0 |
| 230 | 239 | 150 | 0 |
| 267.5 | 279 | 169 | 0 |
| 214 | 215 | 58 | 0 |
| 259 | 279 | 110 | 0 |
| 176.5 | 179.9 | 130 | 0 |
| 144.9 | 149.9 | 149 | 0 |
| 230 | 235 | 114 | 0 |
| 192 | 199.8 | 120 | 0 |
| 195 | 210 | 61 | 0 |
| 212 | 226 | 146 | 0 |
| 146.5 | 149.9 | 137 | 0 |
| 160 | 160 | 281 | 0 |
| 292.5 | 322 | 63 | 0 |
| 179 | 187.5 | 48 | 0 |
| 227 | 247 | 52 |
0 |
Create a box plot for each of the three variables, with Gulf View and No Gulf View condos represented by a separate box. Compare the distributions between the two groups along with the statistics in question (1). Discuss any specific statistical results that would help a real estate agent understand the condominium market. ( Gulf View condos are denoted by “1” in the Gulf View column, whereas No Gulf View condos are denoted by “0”. Prices are in thousands of dollars.)
In: Statistics and Probability
1.
You would like to buy a house that costs$ 350 comma 000$350,000.You have$ 50 comma 000$50,000
in cash that you can put down on the house, but you need to borrow the rest of the purchase price. The bank is offering you a 30-year mortgage that requires annual payments and has an interest rate of
7 %7%
per year. You can afford to pay only
$ 23 comma 210$23,210
per year. The bank agrees to allow you to pay this amount each year, yet still borrow
$ 300 comma 000$300,000.
At the end of the mortgage (in 30 years), you must make a balloon payment; that is, you must repay the remaining balance on the mortgage. How much will be this balloon payment?
Hint: The balloon payment will be in addition to the 30th payment.
2.
You are thinking of building a new machine that will save you
$ 5 comma 000$5,000
in the first year. The machine will then begin to wear out so that the savings decline at a rate of
3 %3%
per year forever. What is the present value of the savings if the interest rate is
8 %8%
per year?
The present value of the savings is $nothing. (Round to the nearest dollar.)
In: Accounting
25)Sosin Inc. manufactures hydrogen engines. Recently 350 new orders placed by customers requesting credit. The variable cost is $16,000 per unit, and the credit price is $18,400 each. Credit is extended for one period, and based on historical experience, payments for 15% of the orders are never collected. The required return is 3% per period. Suppose that customers who don’t default become repeat customers and they never default. Calculate the NPV?
In: Finance
Suppose we have 30-day follow-up data on 350 ischemic stroke patients and want to investigate whether the risk of recurrent stroke and/or death (RD) depends on the type of stroke. You classify patients according to initial stroke type-having a cerebral embolism (CE = 1) or not (CE = 0).
Analysis of Maximum Likelihood Estimates
Standard Wald
Parameter DF Estimate Error Chi-Square Pr>ChiSq
Intercept 1 -2.8034 0.5149 29.639 <0.0001
CE 1 1.8651 0.6479 8.2874 0.0040
Odds Ratio Estimates
Point 95% Wald
Effect Estimate Confidence Limits
CE 6.457 1.814 22.986
a) What is the risk of RD for CE patients?
b) What is the risk of RD for non-CE patients?
c) Is the risk of RD the same for CE and non-CE patients? Estimate the relative risk of RD.
In: Statistics and Probability
1. The equilibrium constant, Kc, for the following
reaction is 9.52×10-2at
350 K.
CH4(g) +
CCl4(g) = 2
CH2Cl2(g)
Calculate the equilibrium concentrations of reactants and product
when 0.300 moles of
CH4and 0.300 moles of
CCl4are introduced into a 1.00 L vessel
at 350 K.
| [ CH4] | = | M |
| [ CCl4] | = | M |
| [ CH2Cl2] | = | M |
2. 2HI(g)
=H2(g) +
I2(g)
If 1.87 moles of HI,
0.335 moles of H2, and
0.211 moles of I2 are
at equilibrium in a 15.6 L container at
748 K, the value of the equilibrium constant,
Kp, is ?
3. The equilibrium constant, Kp, for the following
reaction is 2.01 at 500 K:
PCl3(g) +
Cl2(g)
=PCl5(g)
Calculate the equilibrium partial pressures of all species when
PCl3 and
Cl2, each at an intitial partial
pressure of 0.829 atm, are introduced into an
evacuated vessel at 500 K.
| PPCl3 | = | atm |
| PCl2 | = | atm |
| PPCl5 | = | atm |
4. The equilibrium constant, Kp, for the following
reaction is 1.80×10-2 at
698 K:
2HI(g) =
H2(g) +
I2(g)
Calculate the equilibrium partial pressures of all species when
HI(g) is introduced into an evacuated flask at a
pressure of 1.29 atm at 698
K.
|
PHI |
= |
atm |
|
PH2 |
= |
atm |
|
PI2 |
= |
atm |
In: Chemistry
Target Costing
The president of Houston Electronics was pleased with the company’s newest product, the HE Versatile CVD. The product is portable and can be attached to a computer to play or record computer programs or sound, attached to an amplifier to play or record music, or attached to a television to play or record TV programs. It can even be attached to a camcorder to record videos directly on compact disks rather than on tape. It also can be used with a headset to play or record sound. The proud president announced that this unique and innovative product would be an important factor in reestablishing the North American consumer electronics industry.
Based on development costs and predictions of sales volume, manufacturing costs, and distribution costs, the cost-based price of the HE Versatile CVD was determined to be $425. Following a market-skimming strategy, management set the initial selling price at $525. The marketing plan was to reduce the selling price by $50 during each of the first two years of the product’s life to obtain the highest contribution possible from each market segment.
The initial sales of the HE Versatile CVD were strong, and Houston Electronics found itself
adding second and third production shifts. Although these shifts were expensive, at a selling price of $525, the product had ample contribution margin to remain highly profitable. The president was talking with the company’s major investors about the desirability of obtaining financing for a major plant expansion when the bad news arrived. A foreign company had announced that it would shortly introduce a similar product that would incorporate new design features and sell for only $350. The president was shocked. “Why,” she remarked, “it costs us $375 to put a complete unit in the hands of customers.”
Required
How could the foreign competitor profitably sell a similar product for less than the manufacturing costs to Houston Electronics? What advice do you have for the president concerning the HE Versatile CVD? What advice would you have to help the company avoid similar problems in the future?
In: Accounting
An advertising company wants to know whether the size of an advertisement and the color of the advertisement make a difference in the response of magazine readers. A random sample of readers shown ads of 4 different colors and 3 different sizes. Assume that the ratings follow the normal distribution. The rating is shown in the following table:
|
Size of Ad |
Color of Ad |
|||
|
Red |
Blue |
Orange |
Green |
|
|
Small |
4 |
3 |
3 |
8 |
|
Medium |
3 |
5 |
6 |
7 |
|
Large |
6 |
7 |
8 |
8 |
a. Using the Excel spreadsheet, construct an ANOVA table.
b. Is there a difference in the effectiveness of an advertisement by color at α =.05? (in your answer, you need to indicate F-static and critical value of F)
c. Is there a difference in the effectiveness of an advertisement by size at α =.05 ? (in your answer, you need to indicate F-static and critical value of F)
In: Statistics and Probability