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
garik1379 [7]
3 years ago
5

Define a public static method named s2f that takes two String arguments, the name of a file and some text. The method creates th

e file and writes the text to it. If all goes well the method returns true. If, however, either of its arguments are null or if there is any problem in creating or writing to the file, the method returns false.
Engineering
1 answer:
marin [14]3 years ago
7 0

Answer:

import java.io.IOException;

import java.io.PrintWriter;

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

public class WriteFile {

public static boolean s2f(String fileName,String content)

{

boolean result = true;

if(content == null || fileName == null)

result = false;

else

{

try{

PrintWriter fileWriter = new PrintWriter(fileName, "UTF-8");

fileWriter.println(content);

fileWriter.close();

} catch (IOException e) {

result = false;

}

}

return result;

}

public static void main(String[] args)

{

boolean res = s2f("data.txt","Java is awesome.");

if(res==true)

System.out.println("Successful");

else

System.out.println("There was some error in writing to a file.");

}

}

You might be interested in
An ideal neon sign transformer provides 9130 V at 51.0 mA with an input voltage of 240 V. Calculate the transformer's input powe
BaLLatris [955]

Answer:

Input power = 465.63 W

current = 1.94 A

Explanation:

we have the following data to answer this question

V = 9130

i = 0.051

the input power = VI

I = 51.0 mA = 0.051

= 9130 * 0.051

= 465.63 watts

the current = 465.63/240

= 1.94A

therefore the input power is 465.63 wwatts

while the current is 1.94A

the input power is the same thing as the output power.

4 0
3 years ago
Select the correct answer. Ruby wants to create a cube puzzle game. For that she has to create a cube. Which drafting tool do yo
Alexxx [7]

Answer:

D. a triangle and a T-Square

Explanation:

A T-Square is the best drawing tool to create squares. You would need a squares to create cubes.

3 0
3 years ago
An AC power generator produces 50 A (rms) at 3600 V. The voltage is stepped up to 100 000 V by an ideal transformer and the ener
RSB [31]

Given:

I_{rms} = 50 A

voltage, V = 3600V

step-up voltage, V' = 100000 V

Resistance of line, R = 100\ohm

Solution:

To calculate % heat loss in long distance power line:

Power produced by AC generator, P = 50\times 3600 W

P = 180000 W = 180 kW

At step-up voltage, V = 100000V or 100 kV

current, I = \frac{P}{V'}

I = \frac{1800000}{100000}

I = 1.8 A

Power line voltage drop is given by:

V_{drop} = I\times R

V_{drop} = 1.8\times 100

V_{drop} = 180 V

Power dissipated in long transmission line P_{dissipated} = V_{drop}\times I

Power dissipated in long transmission line P_{dissipated} = 180\times 1.8 = 324 W

% Heat loss in power line, P_{loss} = \frac{P_{dissipated}}{P}\times 100

% Heat loss in power line, P_{loss} = \frac{324}{180000}\times 100

P_{loss} = 0.18%

 

5 0
3 years ago
A wing component on an aircraft is fabricated from an aluminum alloy that has a plane strain fracture toughness of 27 . It has b
Mamont248 [21]

Answer:

The stress level at which fracture will occur for a critical internal crack length of 6.2mm is 135.78MPa

Explanation:

Given data;

Let,

critical stress required for initiating crack propagation Cc = 112MPa

plain strain fracture toughness = 27.0MPa

surface length of the crack = a

dimensionless parameter = Y.

Half length of the internal crack, a = length of surface crack/2 = 8.8/2 = 4.4mm = 4.4*10-³m

Also for 6.2mm length of surface crack;

Half length of the internal crack = length of surface crack/2 = 6.2/2 = 3.1mm = 3.1*10-³m

The dimensionless parameter

Cc = Kic/(Y*√pia*a)

Y = Kic/(Cc*√pia*a)

Y = 27/(112*√pia*4.4*10-³)

Y = 2.05

Now,

Cc = Kic/(Y*√pia*a)

Cc = 27/(2.05*√pia*3.1*10-³)

Cc = 135.78MPa

The stress level at which fracture will occur for a critical internal crack length of 6.2mm is 135.78MPa

For more understanding, I have provided an attachment to the solution.

4 0
4 years ago
Entropy change is evaluated using Eq. 6.2a based on an internally reversible process. Can the entropy change between two states
Vadim26 [7]

Answer:

YES

Explanation:

Entropy is an extensive property of the system entropy change that value of entropy change can be determined for any process between the states whether reversible or not. i have attached the formula to calculate entropy change which is independent of whether the system is reversible or not and can be determined for any process.

4 0
4 years ago
Other questions:
  • A compressor operates at steady state with Refrigerant 134a as the working fluid. The refrigerant enters at 0.24 MPa, 0°C, with
    8·1 answer
  • A spherical seed of 1 cm diameter is buried at a depth of 1 cm inside soil (thermal conductivity of 1 Wm-1K-1) in a sufficiently
    14·1 answer
  • A car is towed into a shop with a no-start problem. The engine cranks but will not fire and run on its own power. The car has a
    9·2 answers
  • Water vapor at 6 MPa, 600 degrees C enters a turbine operating at steady state and expands to 10kPa. The mass flow rate is 2 kg/
    14·1 answer
  • PLS HELPPP!!!!!!!!!!!!!!!
    5·2 answers
  • A 100-ampere resistor bank is connected to a controller with conductor insulation rated 75°C. The resistors are not used in conj
    8·1 answer
  • Which characteristic would atoms of a ferromagnetic material have?A. A lack of electrons B. North and south poles C. A temporary
    9·1 answer
  • lmfsojdkkfjdsskfsaj;fkljsldfkjlsdkfdjs;dklfjsldkfjflkjfkjfldjsdlfgkljshglksdjfghdskjgsdfkfjghlsdfghsdkjfghlskjdfhglskjdfghkjsfhg
    12·1 answer
  • In fuel oil piping systems, all exterior above-grade fill piping shall be __________ when tanks are abandoned or removed.
    14·1 answer
  • Topic 4: Workers Rights Practice Worksheet Crossword Puzzle OSHA Provides Workers the Right to: Across _andmedicalre cords 6. In
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!