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
Using the tables for water, determine the specified property data at the indicated states. In each case, locate the state on ske
Anarel [89]

heres a link! ;)

http://www.econsulat.ro/

5 0
3 years ago
In details and step-by-step, show how you apply the Bubble Sort algorithm on the following list of values. Your answer should sh
astraxan [27]

( 12 17 18 19 25 )

<u>Explanation:</u>

<u>First Pass:</u>

( 19 18 25 17 12 ) –> ( 18 19 25 17 12 ), Here, algorithm compares the first two elements, and swaps since 19 > 18.

( 18 19 25 17 12 ) –> ( 18 19 25 17 12 ), Now, since these elements are already in order (25 > 19), algorithm does not swap them.

( 18 19 25 17 12 ) –> ( 18 19 17 25 12 ), Swap since 25 > 17

( 18 19 17 25 12 ) –> ( 18 19 17 12 25 ), Swap since 25 > 12

<u>Second Pass:</u>

( 18 19 17 12 25 ) –> ( 18 19 17 12 25 )

( 18 19 17 12 25 ) –> ( 18 17 19 12 25 ), Swap since 19 > 17

( 18 17 19 12 25 ) –> ( 18 17 12 19 25 ), Swap since 19 > 12

( 18 17 12 19 25 ) –> ( 18 17 12 19 25 )

<u>Third Pass:</u>

( 18 17 12 19 25 ) –> ( 17 18 12 19 25 ), Swap since 18 > 17

( 17 18 12 19 25 ) –> ( 17 12 18 19 25 ), Swap since 18 > 12

( 17 12 18 19 25 ) –> ( 17 12 18 19 25 )

( 17 12 18 19 25 ) –> ( 17 12 18 19 25 )

<u>Fourth Pass:</u>

( 17 12 18 19 25 ) –> ( 12 17 18 19 25 ), Swap since 17 > 12

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 ), Swap since 18 > 12

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )

Now, the array is already sorted, but our algorithm does not know if it is completed. The algorithm needs one whole pass without any swap to know it is sorted.

<u>Fifth Pass:</u>

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )

6 0
3 years ago
A silicon carbide plate fractured in bending when a blunt load was applied to the plate center. The distance between the fractur
Amanda [17]

Question in order:

A silicon carbide plate fractures in bending when a blunt load was applied to the plate center. The distance between the fracture origin and the mirror/mist boundary on the fracture surface was 0.796 mm. To determine the stress used to break the plate, three samples of the same material were tested and produced the following. What is the estimate of the stress present at the time of fracture for the original plate?

Mirror Radius (mm) Bending Failure Stress (MPa)

0.603                         225

0.203                         368

0.162                         442

Answer:

191 MPa

Explanation:

Failure stress of bending is Inversely proportional to the mirror radius

Bending Stress = \frac{1}{(Mirror Radius)^{n}}

At mirror radius 1 = 0.603 mm   Bending stress 1 = 225 Mpa..............(1)

At mirror radius 2 = 0.203 mm  Bending stress 2 = 368 Mpa...............(2)

At mirror radius 3 = 0.162 mm   Bending stress 3 = 442 Mpa...............(3)

comparing case 1 and 2 using the above equation

\frac{Stress 1}{Stress 2} = ({\frac{Radius 2}{Radius 1}})^{n_1}

\frac{225}{368} = ({\frac{0.203}{0.603}})^{n_1}

0.6114 = (0.3366)^{n_1}

Taking the natural logarithm of both side

ln(0.6114) = n ln(0.3366)

n₁ = ln(0.6114)/ln(0.3366)

n₁ = 0.452

comparing case 2 and 3 using the above equation

\frac{Stress 2}{Stress 3} = ({\frac{Radius 3}{Radius 2}})^{n_2}

\frac{368}{442} = ({\frac{0.162}{0.203}})^{n_2}

0.8326 = (0.7980)^{n_2}

Taking the natural logarithm of both side

ln(0.8326) = n ln(0.7980)

n₂ = ln(0.8326)/ln(0.7980)

n₂ = 0.821

comparing case 1 and 3 using the above equation

\frac{Stress 1}{Stress 3} = ({\frac{Radius 3}{Radius 1}})^{n_3}

\frac{225}{442} = ({\frac{0.162}{0.603}})^{n_3}

0.5090 = (0.2687)^{n_3}

Taking the natural logarithm of both side

ln(0.5090) = n ln(0.2687)

n₃ = ln(0.5090)/ln(0.2687)

n₃ = 0.514

average for n

n = \frac{n_1 + n_2 + n_3}{3}

n = \frac{0.452 +0.821 + 0.514}{3}

n = 0.596

Hence to get bending stress x at mirror radius 0.796

\frac{Stress x}{Stress 3} = ({\frac{Radius 3}{Radius x}})^{0.596}

\frac{Stress x}{225} = ({\frac{0.603}{0.796}})^{0.596}

\frac{Stress x}{225} = 0.8475

stress x = 191 MPa

3 0
3 years ago
The unit weight of a soil is 14.9kN/m3. The moisture content of the soil is17% when the degree of saturation is 60%. Determine:
Serggg [28]

Answer:

a) 2622.903 N/m^3

b) 1.38233

c)4.878811765

Explanation:

Find the void ratio using the formula:

y = \frac{G_{s}*y_{w} + w*G_{s}*y_{w} }{1+e} ....... Eq1

Here;

G_{s} is specific gravity of soil solids

y_{w} is unit weight of water = 998 kg/m^3

w is the moisture content = 0.17

e is the void ratio

y is the unit weight of soil = 14.9KN/m^3

Saturation Ratio Formula:

w*G_{s} = S*e  ..... Eq2

S is saturation rate

Substitute Eq 2 into Eq 1

y = \frac{(\frac{S*e}{w}) * y_{w} + S*e*y_{w}  }{1+e}

14900 = \frac{3522.352941*e + 598.8*e }{1+e} = \frac{4121.152941*e}{1+e}\\\\ e= 1.38233

Specific gravity of soil solids

G_{s} = \frac{S*e}{w} = \frac{0.6*1.38233}{0.17} = 4.878811765

Saturated Unit Weight

y_{s} = \frac{(G_{s} + e)*y_{w}  }{1+e} \\=\frac{(4.878811765 + 1.38233)*998  }{1+1.38233}\\\\= 2622.902571 N/m^3

7 0
3 years ago
A ductile hot-rolled steel bar has a minimum yield strength in tension and compression of 350 MPa. Using the distortion-energy a
Ratling [72]

Answer:

Explanation:

From  the given question:

Using the distortion energy theory to determine the  factors of safety  FOS can be expressed  by the relation:

\dfrac{Syt}{FOS}= \sqrt{ \sigma x^2+\sigma  y^2-\sigma x \sigma y+3 \tau_{xy^2}}

where; syt = strength in tension and compression = 350 MPa

The maximum shear stress theory  can be expressed as:

\tau_{max} = \dfrac{Syt}{2FOS}

where;

\tau_{max} =\sqrt{ (\dfrac{\sigma x-\sigma  y}{2})^2+ \tau _{xy^2

a. Using distortion - energy theory formula:

\dfrac{350}{FOS}= \sqrt{94^2+0^2-94*0+3 (-75)^2}}

\dfrac{350}{FOS}=160.35

{FOS}=\dfrac{350}{160.35}

FOS = 2.183

USing the maximum-shear stress theory;

\dfrac{350}{2 FOS}  =\sqrt{ (\dfrac{94-0}{2})^2+ (-75)^2

\dfrac{350}{2 FOS}  =88.51

\dfrac{350}{ FOS}  =2 \times 88.51

{ FOS}  =\dfrac{350}{2 \times 88.51}

FOS = 1.977

b. σx = 110 MPa, σy = 100 MPa

Using distortion - energy theory formula:

\dfrac{350}{FOS}= \sqrt{ 110^2+100^2-110*100+3(0)^2}

\dfrac{350}{FOS}= \sqrt{ 12100+10000-11000

\dfrac{350}{FOS}=105.3565

FOS=\dfrac{350}{105.3565}

FOS =3.322

USing the maximum-shear stress theory;

\dfrac{350}{2 FOS}  =\sqrt{ (\dfrac{110-100}{2})^2+ (0)^2

\dfrac{350}{2 FOS}  ={ (\dfrac{110-100}{2})^2

\dfrac{350}{2 FOS}  =25

FOS = 350/2×25

FOS = 350/50

FOS = 70

c. σx = 90 MPa, σy = 20 MPa, τxy =−20 MPa

Using distortion- energy theory formula:

\dfrac{350}{FOS}= \sqrt{ 90^2+20^2-90*20+3(-20)^2}

\dfrac{350}{FOS}= \sqrt{ 8100+400-1800+1200}

\dfrac{350}{FOS}= 88.88

FOS = 350/88.88

FOS = 3.939

USing the maximum-shear stress theory;

\dfrac{350}{2 FOS}  =\sqrt{ (\dfrac{90-20}{2})^2+ (-20)^2

\dfrac{350}{2 FOS}  =\sqrt{ (35)^2+ (-20)^2

\dfrac{350}{2 FOS}  =\sqrt{ 1225+ 400

\dfrac{350}{2 FOS}  =40.31

FOS}  =\dfrac{350}{2*40.31}

FOS = 4.341

7 0
3 years ago
Other questions:
  • A bar of steel has the minimum properties Se = 40 kpsi, Sy = 60 kpsi, and Sut = 80 kpsi. The bar is subjected to a steady torsio
    7·1 answer
  • What is the zone that has just been added to the exchange zone where athletes may now hand off the baton
    5·1 answer
  • A curve with 0.3 m constant radius contains a bead that is moving on it such that its rotational velocity is 3t2 sec-1. If the b
    12·1 answer
  • Consider a single crystal of some hypothetical metal that has the BCC crystal structure and is oriented such that a tensile stre
    10·1 answer
  • A process engineer performed jar tests for a water in order to determine the optimal pH and dose using alum. A test was conducte
    13·1 answer
  • Sublimation is to change from
    7·2 answers
  • Why is it important to always be wearing a personal flotation device (PFD) when in or around the water?
    9·2 answers
  • Identify five safety hazards that should be included in the design of the school
    6·1 answer
  • Estimate (a) the maximum, and (b) the minimum thermal conductivity values (in W/m-K) for a cermet that contains 76 vol% carbide
    9·1 answer
  • What color is a board sternlight
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!