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
Water flows at a rate of 10 gallons per minute in a new horizontal 0.75?in. diameter galvanized iron pipe. Determine the pressur
ruslelena [56]

Answer:

\frac{\delta p }{l} = 30.4 lb/ft^3

Explanation:

Given data:

flow rate = 10 gallon per  minute = 0.0223 ft^3/sec

diameter = 0.75 inch

we know discharge is given as

Q =  VA

solve for velocity V = \frac{Q}{A}[/tex]

V = \frac{0.223}{\frac{\pi}{4} \frac{0.75}{12}}

V = 7.27 ft/sec

we know that Reynold number

Re = \frac{VD}{\nu}

Re = \frac{7.27 \times \frac{0.75}{12}}{1.21\times 10^{-5}}

Re = 3.76 \times 10^4

calculate the \frac{\epsilon }{D}ratio to determine the fanning friction f

\frac{\epsilon }{D} = \frac{0.0005}{\frac{0.75}{12}} = 0.008

from moody diagram f value corresonding to Re and \frac{\epsilon }{D}is 0.037

for horizontal pipe

\delta p = \frac{f l \rho v^2}{2D}

\frac{\delta p }{l} = \frac{1 \times 0.037 \times 1.94 \times 7.27}{\frac{0.75}{12}}

where 1.94 slug/ft^3is density of  water

\frac{\delta p }{l} = 30.4 lb/ft^3

3 0
4 years ago
The difference between an initial condition and a boundary condition for conduction in a solid is:___________
leva [86]

Answer:

c. an initial condition specifies the temperature at the start of the problem and a boundary condition provides information about temperatures on the boundaries.

Explanation:

Conduction refers to the transfer of thermal energy or electric charge as a result of the movement of particles. When the conduction relates to electric charge, it is known as electrical conduction while when it relates to thermal energy, it is known as heat conduction.

In the process of heat conduction, thermal energy is usually transferred from fast moving particles to slow moving particles during the collision of these particles. Also, thermal energy is typically transferred between objects that has different degrees of temperature and materials (particles) that are directly in contact with each other but differ in their ability to accept or give up electrons.

Any material or object that allow the conduction (transfer) of electric charge or thermal energy is generally referred to as a conductor. Conductors include metal, steel, aluminum, copper, frying pan, pot, spoon etc.

Hence, the difference between an initial condition and a boundary condition for conduction in a solid is that an initial condition specifies the temperature at the start of the problem and a boundary condition provides information about temperatures on the boundaries.

7 0
3 years ago
What is the resistance of a resistor if the current flowing through it is 3mA and the voltage across it is 5.3V?
Flura [38]

Answer: 1766.667 Ω = 1.767kΩ

Explanation:

V=iR

where V is voltage in Volts (V), i is current in Amps (A), and R is resistance in Ohms(Ω).

3mA = 0.003 A

Rearranging the equation, we get

R=V/i

Now we are solving for resistance. Plug in 0.003 A and 5.3 V.

R = 5.3 / 0.003

= 1766.6667 Ω

= 1.7666667 kΩ

The 6s are repeating so round off to whichever value you need for exactness.

6 0
1 year ago
What is a smooth flow of air over a surface is called?
pochemuha

Answer:

laminar flow

Explanation:

In fluid dynamics, laminar flow is characterized by fluid particles following smooth paths in layers, with each layer moving smoothly past the adjacent layers with little or no mixing.

4 0
3 years ago
Roads in rural areas are _______.
Roman55 [17]

Answer:

Explanation:

Mountain roads often zigzag across a mountain with a series of sharp turns called. switchbacks.

6 0
3 years ago
Read 2 more answers
Other questions:
  • For this question, you will be provided with data related to the count of website sessions by day for the past one hundred days.
    6·1 answer
  • Danny enjoys studying transportation networks and systems. Which field of engineering should he pursue?
    11·1 answer
  • Benzoic acid 1.35 g, is reacted with oxygen in a constant volumecalorimeter to form H2 O(l) and CO2 (g)at 298 K. the mass of the
    7·1 answer
  • What is the main role of matrix in composites! a)-to transfer stress to the other phases b)- to protect phases from environment
    7·1 answer
  • Sophia is designing a new welding shop for the local high school. Where should the compressed gas and fuel cylinders be stored?
    15·1 answer
  • Which of the following is true Select one: a. HTML stands for Hyper Text Markup Language is a language for describing web pages
    6·1 answer
  • A 40 mph wind is blowing past your house and speeds up as it flows up and over the roof. If the elevation effects are negligible
    14·1 answer
  • For laminar flow of air over a flat plate that has a uniform surface temperature, the curve that most closely describes the vari
    15·1 answer
  • Steam enters an adiabatic turbine at 6 MPa, 600°C, and 80 m/s and leaves at 50 kPa, 100°C, and 140 m/s. If the power output of t
    14·1 answer
  • The volume of the pyramid is 36 cubic cm, find the volume of the prism.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!