Assuming dataFile is an ofstream object associated with a disk file named payroll.dat, which of the following statements would write the value of the salary variable to the file
A) cout < B) ofstream C) dataFile << salary;
D) payroll.dat <

Answers

Answer 1

Answer:

dataFile << salary;

Explanation:

To write salary to a file (payroll.dat) using ofstream, you make use of the following instruction:

ofstream dataFile;

myfile.open ("payroll.dat");

myfile <<salary;

myfile.close();

This line creates an instance of ofstream

ofstream dataFile;

This line opens the file payroll.dat

myfile.open ("payroll.dat");

This is where the exact instruction in the question is done. This writes the value of salary to payroll.dat

myfile <<salary;

This closes the opened file

myfile.close();


Related Questions

Consider the following class designed to store weather statistics at a particular date and time:
public class WeatherSnapshot
{
private int tempInFahrenheit;
private int humidity; // value of 56 means 56% humidity
private int dewPoint; // in degrees Fahrenheit
private String date; // stores the date as a String
private int time; // in military time, such as 1430 = 2:30 pm
private boolean cloudy; // true if 25% or more of the sky is covered
// constructor not shown, but it initializes all instance variables
// postcondition: returns temperature
public int getTemp()
{
return tempInFahrenheit;
}
// postcondition: returns date
public String getDate()
{
return date;
}
// postcondition: returns true if precipitation is likely; false otherwise
public boolean precipitationLikely()
{
// implementation not shown
}
// other methods not shown
}
Suppose a WeatherSnapshot object named currentWeather has been correctly instantiated in a client class. Which of the following will correctly call the precipitationLikely method?
A. boolean couldRain = precipitationLikely();
B. boolean couldRain = currentWeather.precipitationLikely();
C. boolean couldRain = currentWeather.precipitationLikely(true);
D. double percentChanceOfRain = precipitationLikely();
E. double percentChanceOfRain = currentWeather.precipitationLikely();

Answers

Answer:

The answer is "Option b".

Explanation:

In this question, It took the boolean parameter, which may use the couldRain as the precipitationLikely precipitation method as the boolean variable because the precipitationLikely is not a static type, and it can name this method utilizing object is called currentWeather, that's why the choice b is correct.

At Moore High, 456 students attended the prom. This is 65 more students than
the previous year.
To the nearest percent, what is the percent of increase from last year to this
year?
12%
15%
17%
19%

Answers

Answer:

B-15%

Explanation:

Yes I agree the answer is B 15%
Other Questions
Lisa says the factors of 18 are 1, 2, 3, 6, and 9. Is Lisa correct? A. Yes, she is correct. B. No, Lisa forgot the factor 4. C. No, Lisa forgot the factor 8. D. No, Lisa forgot the factor 18. A way to build good credit isusing only secured loans.taking out many lines of credit.paying bills when they are due.using only credit cards. PLEASE HELP :( I NEED HELP and tell the steps on how u got it i need to show work What is a good book to read on epic? Any suggestions? HELP ITS DUE RIGHT NOW PLEASE !!! when was the date when the Climate Change In the arctic happened ? What is creating our Earth's Magnetic field?1) Our Earth's iron liquid outer core rotating around the solid inner core2) Our Earth having a stationary inner core3) Our Earth having rocky center4) All of the above A helpful shortcut our brain makes in scene recognition is to assume that lighting comes from: Test Comprehension Read each of the following questions. Then choose the letter of the best answer. This is a answer.DDBADABACCDenada espero que res aya servido Many limericks have well-known authors.TrueFalse Which is the better value?A. 6 ounces of hot Cheetos for $2.16B. 10 ounces of hot Cheetos for $2.70 HElp PLZ DUE RIGHT KNaw 12POINTS Battle of GonzalesBattle of the AlamoBattle of?Conplete the timeline A. MedinaB. San JacintoC. Appomattox D. Lexington How many electrons does H have with a -1 charge A WRONG WAY sign has what color background? A. Blue B. Red C. Brown D. Orange There are 4 boys eating oranges. Each boy eats 1 / 2 of an orange. How many oranges did the boys eat? Help 39 point pic below Math did the cult of Domesticity oppress or empower women in the 19th century The Bills of Rights of both the Texas Constitution and the United States Constitution are mostly concerned withIndividual RightsIndividual RightsNone of the aboveNone of the aboveStates' RightsStates' RightsFederalism why do you think we should wear mask?