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
KatRina [158]
3 years ago
12

Write a simple phonebook program that reads in a series of name-number pairs from the user (that is, name and number on one line

separated by whitespace) and stores them in a Map from Strings to Integers. Then ask the user for a name and return the matching number, or tell the user that the name wasn’t found.
Engineering
1 answer:
Vlad1618 [11]3 years ago
6 0

Answer:

import java.util.HashMap;

import java.util.Map;

import java.util.Scanner;

public class PhoneBook {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       Map<String, String> map = new HashMap<>();

       String name, number, choice;

       do {

           System.out.print("Enter name: ");

           name = in.next();

           System.out.print("Enter number: ");

           number = in.next();

           map.put(name, number);

           System.out.print("Do you want to try again(y or n): ");

           choice = in.next();

       } while (!choice.equalsIgnoreCase("n"));

       System.out.print("Enter name to search for: ");

       name = in.next();

       if (map.containsKey(name)) {

           System.out.println(map.get(name));

       } else {

           System.out.println(name + " is not in the phone book");

       }

   }

}

You might be interested in
A gas within a piston–cylinder assembly undergoes an isothermal process at 400 K during which the change in entropy is 20.3 kJ/K
Mashcka [7]

Answer:

W= 8120 KJ

Explanation:

Given that

Process is isothermal ,it means that temperature of the gas will remain constant.

T₁=T₂ = 400 K

The change in the entropy given ΔS = 20.3 KJ/K

Lets take heat transfer is Q ,then entropy change can be written as

\Delta S=\dfrac{Q}{T}

Now by putting the values

20.3=\dfrac{Q}{400}

Q= 20.3 x 400 KJ

Q= 8120 KJ

The heat transfer ,Q= 8120 KJ

From first law of thermodynamics

Q = ΔU + W

ΔU =Change in the internal energy ,W=Work

Q=Heat transfer

For ideal gas ΔU  = m Cv ΔT]

At constant temperature process ,ΔT= 0

That is why ΔU  = 0

Q = ΔU + W

Q = 0+ W

Q=W= 8120 KJ

Work ,W= 8120 KJ

8 0
3 years ago
A steel rule can be used to check for
MAXImum [283]
I THINK THE ANSWER IS B BUT IM NOT SURE OK BYE
3 0
3 years ago
The brakes are being bled on a passenger vehicle with a disc/drum brake system. Technician A says that the drums should be remov
exis [7]

The brakes are being bled on a passenger vehicle with a disc/drum brake system is described in the following

Explanation:

1.Risk: Continued operation at or below Rotor Minimum Thickness can lead to Brake system failure. As the rotor reaches its minimum thickness, the braking distance increases, sometimes up to 4 meters. A brake system is designed to take kinetic energy and transfer it into heat energy.

2.Since the piston needs to be pushed back into the caliper in order to fit over the new pads, I do open the bleeder screw when pushing the piston back in. This does help prevent debris from traveling back through the system and contaminating the ABS sensors

3.There are three methods of bleeding brakes: Vacuum pumping. Pressure pumping. Pump and hold.

4,Brake drag is caused by the brake pads or shoes not releasing completely when the brake pedal is released. ... A worn or corroded master cylinder bore causes excess pedal effort resulting in dragging brakes. Brake Lines and Hoses: There may be pressure trapped in the brake line or hose after the pedal has been released.

4 0
3 years ago
Which of the following is true about ideal standards? a.Ideal standards provide allowance for normal breakdowns and interruption
marysya [2.9K]

Answer: D. All of the choice A, B and C are correct.

8 0
3 years ago
A plane, opaque, surface M has the following properties: gray, diffuse, absorptivity = 0.7, surface area = 0.5 m2 , temperature
BaLLatris [955]

Answer:

The rate of energy absorbed per unit time is 3500W.

Explanation:

From the question, we were given the following parameters;

Plane, opaque, gray, diffuse surface

â = 0.7

Surface area, A = 0.5m²

Incoming radiant energy, G = 10000w/m²

T = 500°C

Rate of energy absorbed is âAG;

âAG = 0.7 × 0.5 × 10000

âAG = 3500W.

The energy absorbed is measured in watts and denoted by the symbol W.

7 0
3 years ago
Other questions:
  • Refectories are one of the types of ceramics that have low melting temperature. a)-True b)-False
    7·1 answer
  • The wheel and the attached reel have a combined weight of 50lb and a radius of gyration about their center of 6 A k in = . If pu
    9·1 answer
  • If you were choosing between two strain gauges, one which has a single resistor in a bridge that varies and one that has two res
    11·1 answer
  • // This program accepts data about 100 books and// determines a price for each.// The price is 10 cents per page for the// first
    12·1 answer
  • When you arrive at an intersection with a stop sign in your direction, if there is no marked stop
    14·2 answers
  • An air-conditioning system operating on the reversed Carnot cycle is required to transfer heat from a house at a rate of 755 kJ/
    7·1 answer
  • All brake lights are dimmer than normal. Technician A says that bad bulbs could be the cause. Technician B says that high resist
    6·1 answer
  • What financial arguments could you use to justify your proposed
    14·1 answer
  • 3. Which instrument measures the height above the ground?
    8·1 answer
  • A technician needs to check the heating operation of a heat pump that has no gauge access ports. The technician should start by:
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!