1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
My name is Ann [436]
3 years ago
9

Assuming dataFile is an ofstream object associated with a disk file named payroll.dat, which of the following statements would w

rite the value of the salary variable to the file
A) cout < B) ofstream C) dataFile << salary;
D) payroll.dat <
Computers and Technology
1 answer:
svet-max [94.6K]3 years ago
8 0

Answer:

dataFile << salary;

Explanation:

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

<em>ofstream dataFile; </em>

<em>myfile.open ("payroll.dat"); </em>

<em>myfile <<salary; </em>

<em>myfile.close();</em>

<em />

This line creates an instance of ofstream

<em>ofstream dataFile; </em>

This line opens the file payroll.dat

<em>myfile.open ("payroll.dat"); </em>

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

<em>myfile <<salary; </em>

This closes the opened file

<em>myfile.close();</em>

<em />

<em />

You might be interested in
Define a method named swapValues that takes an array of four integers as a parameter, swaps array elements at indices 0 and 1, a
Luba_88 [7]

The program is an illustration of arrays.

Arrays are used to hold multiple values.

The program in java, where comments are used to explain each line is as follows:

import java.util.*;

public class Main{

   //This defines the method

public static int[] swapValues(int[] arr) {

   //This swaps the first and second array elements

       int temp = arr[0];

       arr[0] = arr[1];   arr[1] = temp;

   //This swaps the third and fourth array elements

       temp = arr[2];

       arr[2] = arr[3];   arr[3] = temp;

   //This returns the swapped array to main

       return arr;

}

//The main method begins here

   public static void main(String[] args) {

       //This creates a Scanner object

       Scanner input = new Scanner(System.in);

 //This declares an array of 4 elements

 int[] intArray = new int[4];

 //This gets input for the array

 for(int i = 0; i<4;i++){

     intArray[i] = input.nextInt();

 }

 //This calls the swapValues method

 intArray=swapValues(intArray);

 //This prints the swapped array

 for (int i = 0; i < 4; i++){

 System.out.print( intArray[i]+ " ");     }

}  

}

At the end of the program, the elements are swapped and printed.

Read more about similar programs at:

brainly.com/question/14017034

6 0
3 years ago
Within a major students can choose to study a specific area within major. For example a journalism student may study military jo
Tpy6a [65]

Answer:

Specialization

Hope this helps!

6 0
3 years ago
9. which of the following cities is not considered one of the top game development hotbeds?
Kitty [74]

Answer:

9. C

10. C

Explanation:

I hope it can help

3 0
3 years ago
Bill is pushing a box with 10 N of force to the left, while Alice is pushing the box with 30 N of force to the right. What is th
Greeley [361]

Answer:

Net force = 20 N

Explanation:

Given that,

Force acting on the left = 10 N

Force acting on the right = 30 N

Let right side is positive and left side is negative. Let the net force acting on the box is F. So,

F = -10+30

F = 20 N

So, the net force on the box is 20 N and it is in right side.

7 0
3 years ago
Can you use public domain images without violating copyright laws?
Oksana_A [137]
There are no restrictions on using works that are in the public domain, which means you can use them however you want—short of claiming that you created them yourself.

Hope this helps
3 0
4 years ago
Other questions:
  • Which is not a factor that leads to technological advancement?
    14·1 answer
  • Thegroup of technologies concerned with the capturing, processing and transmissionof information in the digital electronic form
    9·1 answer
  • Green field country is planning to conduct a cricket match between two teams A and B. a large crowd is expected in the stadium a
    6·1 answer
  • All NATE specialties are offered at two levels, A. journeyman and master. B. installation and service. C. apprentice and journey
    7·1 answer
  • Mention 5 advantages of internet​
    8·1 answer
  • Power point is hardware or software​
    12·2 answers
  • THE DIFFERENCE BETWEEN COPY AND PASTE AND CUT AND PASTE IS: *
    5·2 answers
  • Your iphone is not configured to allow calls using this mac
    10·1 answer
  • Which step do you think is most useful from big data life cycle and why?
    12·1 answer
  • Select a software package/electronic device that you know well. It can be from any domain (work related, entertainment, desktop,
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!