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
yuradex [85]
3 years ago
7

Write code (ReverseNames.java) that prompts the user to enter his or her full name, then prints the name in reverse order (i.e.,

last name, first name). You may assume that only a first and last name will be given. Here is a sample dialogue with the user:

Engineering
1 answer:
yan [13]3 years ago
5 0

Answer:

import java.util.Scanner;

import java.io.*;

public class Main{

    public static void main(String []args){

       

       StringBuilder reversedName = new StringBuilder();

       StringBuilder subName = new StringBuilder();

       

       Scanner myObj = new Scanner(System.in);  // Create a Scanner object

       System.out.println("Enter your full name (last name + first name)");

   

       String name = myObj.nextLine();  // Read user input

       

       for (int i = 0; i < name.length(); i++) {

           

           char currentChar = name.charAt(i);

           

           if (currentChar != ' ') {

               subName.append(currentChar);

           } else {

               reversedName.insert(0, currentChar + subName.toString());

               subName.setLength(0);

           }

       }

       String Resul = reversedName.insert(0, subName.toString()).toString();

       System.out.println("Reverse full name: " + Resul);

    }

}

Explanation:

To solve the problem we used StringBuilder, that allow us to build a string letter by letter, we are using two, one to store temporary information (subName) and the other to store the surname plus name (reversedName). After defining the variables, the program asks for the user fullname using Scanner class and it's method .nextLine (the variable 'name' will save the user input). A while loop is also used to iterate over the name, taking character by character with the method .charAt, the program will append letters in subName until it finds a space only then the content of subName will be transfer to reversedName and the content of subName will be deleted, then the program continues with the process until the end of the for loop; finally, the program places the content of subName at the beginning of reversedName, and print the result transforming the StringBuilder to a normal string.

You might be interested in
A furnace wall composed of 200 mm, of fire brick. 120 mm common brick 50mm 80% magnesia and 3mm of steel plate on the outside. I
Liula [17]

Answer:

  • fire brick / common brick : 1218 °C
  • common brick / magnesia : 1019 °C
  • magnesia / steel : 90.06 °C
  • heat loss: 4644 kJ/m^2/h

Explanation:

The thermal resistance (R) of a layer of thickness d given in °C·m²·h/kJ is ...

  R = d/k

so the thermal resistances of the layers of furnace wall are ...

  R₁ = 0.200/4 = 0.05 °C·m²·h/kJ

  R₂ = 0.120 2.8 = 3/70 °C·m²·h/kJ

  R₃ = 0.05/0.25 = 0.2 °C·m²·h/kJ

  R₄ = 0.003/240 = 1.25×10⁻⁵ °C·m²·h/kJ

So, the total thermal resistance is ...

  R₁ +R₂ +R₃ +R₄ = R ≈ 0.29286 °C·m²·h/kJ

__

The rate of heat loss is ΔT/R = (1450 -90)/0.29286 = 4643.70 kJ/(m²·h)

__

The temperature drops across the various layers will be found by multiplying this heat rate by the thermal resistance for the layer:

  fire brick: (4543.79 kJ/(m²·h))(0.05 °C·m²·h/kJ) = 232 °C

so, the fire brick interface temperature at the common brick is ...

  1450 -232 = 1218 °C

For the next layers, the interface temperatures are ...

  common brick to magnesia = 1218 °C - (3/70)(4643.7) = 1019 °C

  magnesia to steel = 1019 °C -0.2(4643.7) = 90.06 °C

_____

<em>Comment on temperatures</em>

Most temperatures are rounded to the nearest degree. We wanted to show the small temperature drop across the steel plate, so we showed the inside boundary temperature to enough digits to give the idea of the magnitude of that.

5 0
3 years ago
A rectangular block of material with shear modulus G= 620 MPa is fixed to rigid plates at its top and bottom surfaces. Thelower
PIT_PIT [208]

Answer:

γ_{xy} =0.01, P=248 kN

Explanation:

Given Data:

displacement = 2mm ;

height = 200mm ;

l = 400mm ;

w = 100 ;

G = 620 MPa = 620 N//mm²;    1MPa = 1N//mm²

a. Average Shear Strain:

The average shear strain can be determined by dividing the total displacement of plate by height

γ_{xy} = displacement / total height

     = 2/200 = 0.01

b. Force P on upper plate:

Now, as we know that force per unit area equals to stress

τ = P/A

Also,  τ = Gγ_{xy}

By comapring both equations, we get

P/A = Gγ_{xy}   ------------ eq(1)

First we need to calculate total area,

A = l*w = 400 * 100= 4*10^4mm²

By putting the values in equation 1, we get

P/40000 = 620 * 0.01

P = 248000 N or 2.48 *10^5 N or 248 kN

6 0
3 years ago
Handsaw teeth are very sharp: to avoid being cut by the teeth, keep hands and fingers well away from the
siniylev [52]
Handsaw teeth are very sharp: to avoid being cut by the teeth, keep hands and fingers well away from the
path of the blade
6 0
3 years ago
Read 2 more answers
Rear axles are usually lubricated by the same gear oil that lubricates the differential. True or false
KIM [24]

Answer:

true

Explanation:

8 0
2 years ago
A rigid tank contains 1 kg of oxygen (O2) at p1 = 35 bar, T1 = 180 K. The gas is cooled until the temperature drops to 150 K. De
andreyandreev [35.5K]

Answer:

a. Volume = 13.36 x 10^-3 m³ Pressure = 29.17 bar  b. Volume = 14.06 x 10^-3 m³ Pressure = 22.5 bar

Explanation:

Mass of O₂ = 1kg, Pressure (P1) = 35bar, T1= 180K, T2= 150k Molecular weight of O₂ = 32kg/Kmol

Volume of tank and final pressure using a)Ideal Gas Equation and b) Redlich - Kwong Equation

a. PV=mRT

V = {1 x (8314/32) x 180}/(35 x 10⁵) = 13.36 x 10^-3

Since it is a rigid tank the volume of the tank must remain constant and hnece we can say

T2/T1 = P2/P1, solving for P2

P2 = (150/180) x 35 = 29.17bar

b. P1 = {RT1/(v1-b)} - {a/v1(v1+b)(√T1)}

where R, a and b are constants with the values of, R = 0.08314bar.m³/kmol.K, a = 17.22(m³/kmol)√k, b = 0.02197m³/kmol

solving for v1

35 = {(0.08314 x 180)/(v1 - 0.02197)} - {17.22/(v1)(v1 + 0.02197)(√180)}

35 = {14.96542/(v1-0.02197)} - {1.2835/v1(v1 + 0.02197)}

Using Trial method to find v1

for v1 = 0.5

Right hand side becomes =  {14.96542/(0.5-0.02197)} - {1.2835/0.5(0.5 + 0.02197)} = 31.30 ≠ Left hand side

for v1 = 0.4

Right hand side becomes =  {14.96542/(0.4-0.02197)} - {1.2835/0.4(0.4 + 0.02197)} = 39.58 ≠ Left hand side

for v1 = 0.45

Right hand side becomes =  {14.96542/(0.45-0.02197)} - {1.2835/0.45(0.45 + 0.02197)} = 34.96 ≅ 35

Specific Volume = 35 m³/kmol

V = m x Vspecific/M = (1 x 0.45)/32 = 14.06 x 10^-3 m³

For Pressure P2, we know that v2= v1

P2 = {RT2/(v2-b)} - {a/v2(v2+b)(√T2)} = {(0.08314 x 150)/(0.45 - 0.02197)} - {17.22/(0.45)(0.45 + 0.02197)(√150)} = 22.5 bar

3 0
3 years ago
Other questions:
  • What is the damped natural frequency (in rad/s) of a second order system whose undamped natural frequency is 25 rad/s and has a
    15·1 answer
  • suppose we number the bytes in a w-bit word from 0 (less significant) to w/8-1 (most significant). write code for the followign
    11·1 answer
  • A closed, rigid, 0.45 m^3 tank is filled with 12 kg of water. The initial pressure is p1 = 20 bar. The water is cooled until the
    15·1 answer
  • Select the correct answer.<br> Which equation gives you the amount of work performed?
    14·1 answer
  • Two common methods of improving fuel efficiency of a vehicle are to reduce the drag coefficient and the frontal area of the vehi
    14·1 answer
  • Refrigerant-134a enters an adiabatic compressor at -30oC as a saturated vapor at a rate of 0.45 m3 /min and leaves at 900 kPa an
    13·1 answer
  • QUESTÃO 13. Explique o uso das aspas no trecho "Darei a cada uma de vocês
    12·1 answer
  • How does a belt operated supercharger work? (Not a turbo charger)
    12·1 answer
  • If y varies inversely as x, and y =23 when x=8, find y when x=4
    14·1 answer
  • Which emission is created by the heat in the combustion process?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!