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
Explain the process of energy conversion by describing how energy was converted from the windmill design brief. Discuss the diff
cupoosta [38]

Answer:

Wind energy is converted to Mechanical energy  which is then converted in to  electrical energy

Explanation:

In a wind mill the following energy conversions take place

a) Wind energy is converted into Mechanical energy (rotation of rotor blades)

b) Mechanical energy is converted into electrical energy (by using electric motor)

This electrical energy is then used for transmission through electric lines.

6 0
2 years ago
We can model a certain battery as a voltage source in series with a resistance. The open-circuit voltage of the battery is 10 V
Angelina_Jolie [31]

Answer:

51.4 Ohms

Explanation:

By applying voltage division rule

V_f=v_i\times \frac {R_l}{R_l+R_m} where v is voltage, subscripts i and f represnt initial and final, R is resistance, m is internal and l is external.Substituting 7V for final voltage, 10V for initial voltage and the external resistance as 120 Ohms then

7=10*\frac {120}{120+R_m}\\7R_m+840=1200\\R_m={1200-840}{7}=51.428571\approx 51.4 Ohms

3 0
3 years ago
A rigid bar pendulum is attached to a cart, which moves along the horizontal plane. The rigid bar has a center of mass at L/2. T
Vikentia [17]

Answer:

See the attached picture for answer.

Explanation:

See the attached picture for explanation.

4 0
3 years ago
Why is sssniperwolf so fine
RSB [31]
Bc she’s just a baddie
5 0
3 years ago
Read 2 more answers
Substances A and B have retention times of 16.63 and 17.63 min, respectively, on a 30 cm column. An unretained species passes th
Svet_ta [14]

Answer:

The time required to elute the two species is 53.3727 min

Explanation:

Given data:

tA = retention time of A=16.63 min

tB=retention time of B=17.63 min

WA=peak of A=1.11 min

WB=peak of B=1.21 min

The mathematical expression for the resolution is:

Re_{s} =\frac{2(t_{B}-t_{A})}{W_{A}+W_{B} } =\frac{2*(17.63-16.63)}{1.11+1.21} =0.8621

The mathematical expression for the time to elute the two species is:

\frac{t_{2}}{t_{1}} =(\frac{Re_{B} }{Re_{s} } )^{2}

Here

ReB = 1.5

t_{2} =t_{1} *(\frac{Re_{B} }{Re_{s} } )^{2} =17.63*(\frac{1.5}{0.8621} )^{2} =53.3727min

6 0
3 years ago
Other questions:
  • A room has a width of 14.1 feet, a length of 15.5 feet, and a ceiling height of 12.0 ft. The average flow rate for this room's a
    6·1 answer
  • Methane and oxygen react in the presence of a catalyst to form formaldehyde. In a parallel reaction, methane is oxidized to carb
    12·1 answer
  • A capillary tube is immersed vertically in a water container. Knowing that water starts to evaporate when the pressure drops bel
    11·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
  • Unwanted resistance is being discussed.
    12·1 answer
  • Find the sum and product of each of these pairs of numbers. Express your answers as a base 3 expansion. Hint: We can just add an
    5·1 answer
  • Please write the command(s) you should use to achieve the following tasks in GDB. 1. Show the value of variable "test" in hex fo
    5·1 answer
  • Name some technical skills that are suitable for school leavers .​
    8·1 answer
  • 25 In differential aeration corrosion, rich oxygenated parts are
    14·1 answer
  • If you’re still enrolled in school, but are looking for a job, on your resume you should highlight:
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!