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
The air velocity in the duct of a heating system is to be measured by a Pitot-static probe inserted into the duct parallel to th
Ilia_Sergeevich [38]

Answer:

Flow velocity

50.48m/s

Pressure change at probe tip

1236.06Pa

Explanation:

Question is incomplete

The air velocity in the duct of a heating system is to be measured by a Pitot-static probe inserted into the duct parallel to the flow. If the differential height between the water columns connected to the two outlets of the probe is 0.126m, determine (a) the flow velocity and (b) the pressure rise at the tip of the probe. The air temperature and pressure in the duct are 352k and 98 kPa, respectively

solution

In this question, we are asked to calculate the flow velocity and the pressure rise at the tip of probe

please check attachment for complete solution and step by step explanation

8 0
3 years ago
How does the human body use phospholipids ?
Shtirlitz [24]
Phospholipids are crucial for building the protective barrier, or membrane, around your body's cells. In fact, phospholipids are synthesized in the body to form cell and organelle membranes. In blood and body fluids, phospholipids form structures in which fat is enclosed and transported throughout the bloodstream.
6 0
3 years ago
Read 2 more answers
Of the following answers, which is NOT a way for employees to control exposure routes?
Katena32 [7]

Answer:  Of the following answers, which is NOT a way for employees to control exposure routes?

Explanation:

4 0
3 years ago
Occasionally, one exits a freeway on the left, but most exit ramps are on the ___________ side of the road.
Aliun [14]

Answer:

Right

Explanation:

That's it

8 0
3 years ago
Carbon dioxide gas enters a well-insulated diffuser at 20 lbf/in.2 , 500R, with a velocity of 800 ft/s through a flow area of 1.
inessss [21]

Answer:

Exit Temperature= T2=563.6 °R

Exit Pressure= P2= 30.06 lbf/in^2

Mass Flow rate=1.276 lb/sec

Explanation:

Answer is explained in detailed way in the attached files.

4 0
3 years ago
Other questions:
  • Two soils are fully saturated with liquid (no gas present) and the soils have the same void ratio. One soil is saturated with wa
    9·1 answer
  • A beam spans 25 feet and carries a uniformly distributed dead load equal to 0.6 klf (including beam self-weight) and a live load
    9·1 answer
  • g A food department is kept at -12oC by a refrigerator in an environment at 30oC. The total heat gain to the food department is
    7·1 answer
  • A strain gage is carefully matched with three fixed-bridge resistors, each having a resistance of 120 2 The gage factor is 2.05,
    9·1 answer
  • What is the maximum value of the bending stress at the critical cross-section?
    14·1 answer
  • You are the project manager assigned to construct a new 10-story office building. You are trying to estimate the costs for this
    10·1 answer
  • Explain biometric senser.​
    10·2 answers
  • Tech A says you can find the typical angle of a V-block engine by dividing the number of cylinders by 720
    11·1 answer
  • Select the correct answer. Which physical quantity measures the rate at which an object’s velocity changes?
    11·1 answer
  • What is the magnitude of the charge of an electron?​
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!