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 heat pump operates on a vapor-compression refrigeration cycle with R-134a as the working fluid. The refrigerant enters the com
Rudiy27

Answer:

Hello your question has some missing information below are the missing information

The refrigerant enters the compressor as saturated vapor at 140kPa Determine The coefficient of performance of this heat pump

answer : 2.49

Explanation:

For  vapor-compression refrigeration cycle

P1 = P4  ; P1 = 140 kPa

P2( pressure at inlet ) = P3 ( pressure at outlet ) ; P2 = 800 kPa

<u>From pressure table of R 134a refrigerant</u>

h1 ( enthalpy of saturated vapor at 140kPa ) = 239.16 kJ/kg

h2 ( enthalpy of saturated liquid at P2 = 800 kPa and t = 60°C )

= 296.8kJ/kg

h3 ( enthalpy of saturated liquid at P3 = 800 kPa ) = 95.47 kJ/kg

also h4 = 95.47 kJ/kg

To determine the coefficient of performance  

Cop = ( h1 - h4 ) / ( h2 - h1 )

∴ Cop = 2.49

3 0
2 years ago
Heather is troubleshooting a computer at her worksite. She has interviewed the computer’s user and is currently trying to reprod
Luba_88 [7]

Answer:

The correct option is A

Explanation:

Heather is trying to establish a theory of probable cause. In this step of the troubleshooting process, the person troubleshooting questions the obvious and then test the theory or response given by the user to really determine the cause. Once confirmation of this theory has been achieved, the troubleshooter then tries to establish a resolution to the problem. However in the event whereby the theory is not confirmed, the troubleshooter then tries to establish a new theory.

8 0
3 years ago
BRO FNAF ANIMATRONICS ALL OF THEM INCLUDING THE BOOKS AND THE OTHER ONES IN FNAF SPECIAL DELIVERY!
Nezavi [6.7K]
Nice nice. . . . . . .
9 0
3 years ago
Read 3 more answers
- WHEN YOU ARE TOWING A TRAILER:
zheka24 [161]

Answer:

And Im still going with B..

7 0
3 years ago
You are testing a new jet engine in a test cell at sea level conditions. You measure the mass flow through the engine and find i
bulgar [2K]

Answer:

43248 newtons.

Explanation:

Force = mass x accelerations and units of force are newtons which are given in the question.

here mass = 125 of air and 2.2 of fuel, total = 125+2.2=127.5kg/s  and the velocity of the exhaust is 340m/s.

force = 340m/s * 127.5kg/s = 43248 newtons technically this is wrong (observe units) but i will expalin how i have taken acceleration as a velocity here and mass/unit time as simply mass.

see force is mass times acceleration or deceleration, here our velocity is not changing therefore it is constant 340m/s but if it were to change and become 0 in one second then there would be -340m/s^2 (note the units ) of deceleration and there would be force associated with it and that force is what i have calculated here. similarly there would be mass in flow rate of mass per second, which is also in that one second of time.

let's calculate error.

error = (actual-calculated)/actual. = (43248-60000)/43248= -38.734% less is ofcourse greater than 2%.

So the load cell is not reading correct to within 2% and it should read 43248newtons.

5 0
2 years ago
Read 2 more answers
Other questions:
  • Sarah is developing a Risk Assessment for her organization. She is asking each department head how long can they be without thei
    6·1 answer
  • One cylinder in the diesel engine of a truck has an initial volume of 650 cm3 . Air is admitted to the cylinder at 35 ∘C and a p
    7·1 answer
  • DO NOW: Name the three main legal categories of ownership.
    12·1 answer
  • An inductor has a 50.0-Ω reactance when connected to a 60.0-Hz source. The inductor is removed and then connected to a 45.0-Hz s
    15·1 answer
  • Does the Diesel engine have engine knock or detonation problem? Why?
    6·1 answer
  • The assignment is to modify the class implementation without changing the functionality. Remove the feet and inches data members
    6·1 answer
  • (2 points) A perfectly mixed aeration pond with no recycle serves as the biological reactor for a small community. The pond rece
    15·1 answer
  • A binary liquid system exhibits LLE at 25°C. Determine from each of the following sets of miscibility data estimates for paramet
    10·1 answer
  • Do you know who Candice is
    8·2 answers
  • Compare the temperature dependence of Nabarro-Herring and Coble creep. Which is more temperature-sensitive
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!