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]
2 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]2 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 student is building a circuit which material should she use for the wires and why?
Nataliya [291]

Answer:

i think it is D tell me if its wrong

Explanation:

6 0
3 years ago
Read 2 more answers
These tadpoles are confined to a limited environment. What are they all competing for in that environment
Dovator [93]

Answer: to the earth air

Explanation:

5 0
3 years ago
Read 2 more answers
The following median grain size data were obtained during isothermal liquid phase sintering of an 82W-8Mo-8Ni-2Fe alloy. What is
Morgarella [4.7K]

Answer:

The probable grain-coarsening mechanism is : Ideal grain growth mechanism

( d^{2}- d_{0} ^{2} = kt )

Explanation:

The plot attached below shows the time dependence of the growth of grain.

The probable grain-coarsening mechanism is : Ideal grain growth mechanism

the ideal growth follows this principle = d^{2} - d^{2} _{0}  = kt

d = final grain size

d_{0} = initial grain size

k = constant ( temperature dependent )

t = 0

8 0
3 years ago
Consider a resistor made of pure silicon with a cross-sectional area pf 0.5 μm2, and a length of 50 μm. What is the resistance o
lukranit [14]

Answer: 24 pA

Explanation:

As pure silicon is a semiconductor, the resistivity value is strongly dependent of temperature, as the main responsible for conductivity, the number of charge carriers (both electrons and holes) does.

Based on these considerations, we found that at room temperature, pure silicon resistivity can be approximated as 2.1. 10⁵  Ω  cm.

The resistance R of a given resistor, is expressed by the following formula:

R = ρ L / A

Replacing by the values for resistivity, L and A, we have

R = 2.1. 10⁵ Ω  cm. (10⁴ μm/cm). 50 μm/ 0.5 μm2

R = 2.1. 10¹¹ Ω

Assuming that we can apply Ohm´s Law, the current that would pass through this resistor for an applied voltage of 5 V, is as follows:

I = V/R = 5 V / 2.1.10¹¹ Ω = 2.38. 10⁻¹¹ A= 24 pA

7 0
3 years ago
Explain how smart materials can be used by manufacturers to improve health and safety for children's products and goods.​
Ierofanga [76]

...simplify devices, reducing weight and the chance of failure.

6 0
1 year ago
Other questions:
  • If you know that the change in entropy of a system where heat was added is 12 J/K, and that the temperature of the system is 250
    10·1 answer
  • suppose a wheel with a 15 inch diameter is used to turn a water valve stem with a radius of .95 inches. What is the Mechanical a
    15·1 answer
  • A wall in a house contains a single window. The window consists of a single pane of glass whose area is 0.15 m2 and whose thickn
    10·1 answer
  • Question 11 (1 point)
    12·1 answer
  • The Review_c object has a lookup relationship up to the Job_Application_c object. The job_Application_c object has a master-deta
    7·1 answer
  • A flat-plate solar collector is 2 m long and 1 m wide and is inclined 60o to the horizontal. The cover plate is separated from t
    13·1 answer
  • Sadadasdasdasdasdadaaasd1
    14·1 answer
  • Zack's new home is progressing well, and the foundation work is finished. The general contractor stops by Zack's present home to
    11·1 answer
  • Safety-in engineering as with everything else is all about trying to maximize or create the hazards involved with what you are d
    6·2 answers
  • Where would outdoor Air quality monitors need to be placed to properly record data?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!