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
anastassius [24]
2 years ago
15

A personal phone directory contains room for first names and phone numbers for 30 people. Assign names and phone numbers for the

first 10 people. Prompt the user for a name, and if the name is found in the list, display the corresponding phone number. If the name is not found in the list, prompt the user for a phone number, and add the new name and phone number to the list. Continue to prompt the user for names until the user enters quit. After the arrays are full (containing 30 names), do not allow the user to add new entries. Use the following names and phone numbers: Name Phone # Gina (847) 341-0912 Marcia (847) 341-2392 Rita (847) 354-0654 Jennifer (414) 234-0912 Fred (414) 435-6567 Neil (608) 123-0904 Judy (608) 435-0434 Arlene (608) 123-0312 LaWanda (920) 787-9813 Deepak (930) 412-0991
Computers and Technology
1 answer:
Fynjy0 [20]2 years ago
4 0

Answer:

# include <iostream.h>

# include <stdio.h>

# include <string.h>

using namespace std;

class citizen

{      

    int i;

    public string name[30];

    public long int phonenumber[30];

    public void addindividual(string name1)

     {      

           If (i<=30)

            {     int flag=0;

                  for(int j=0; j<=i;j++)

                  {

                     if (strcmp(name[i], name1)

                      {

                          flag=1;

                      }

                     else

                     {  

                           flag=0;

                     }

                  }

                  If (flag)

                 {

                  if (i<30)

                  {

                  for(j=i+1;j<=30; j++)

                  {

                        cout<<"Enter the name:"; getchar(name[j]);

                        cout<<"Enter the phone number:"; cin>>phonenumber[j];

                         i++;

                   }

                  else  

                   {

                        cout<<"The person already exists";

                        exit();

                   }

              }

            else

             {

                 cout<<"array is full:";

                 exit();

             }

     }

}

Void main()

{

     string str;

    cout<<" Enter name:";

    getline(cin, str); ;

     citizen c1=new citizen();

     c1.addindividual(name1);

}

Explanation:

With a little more effort you can make the program allow the user to enter any number of details, but less than 30 overall. We have used here flag, and as a programmer we know why we use the Flag. It is used to check whether certain Boolean condition is fulfilled or not. Here, we are checking whether a given name is present in the array of names, and if it is not present, we add that to the list. And if the name is present, we print, it already exist.

You might be interested in
We must know the Inflation Rate and the Nominal GDP in order to calculate Real GDP.
Leya [2.2K]
<span>We must know the Inflation Rate and the Nominal GDP in order to calculate Real GDP.


True</span>
7 0
3 years ago
When approaching a bicyclist from the rear, you should slow down and
Veronika [31]

Answer:

A. Wait until it is safe to pass the bicyclist with at least three feet of clearance.

Explanation:

This is one of the traffic safety precautions to follow when driving especially in most parts of the United States of America.

Traffic safety guidelines are a list of Rules and instructions usually available in manuals and online made available by the government to its driving population in order to maintain law and order and prevent accidentals on the road. When effectively followed this guidelines can help to reduce accidents by a high Margin.

4 0
3 years ago
Which of the following is a template definition?
musickatia [10]

Answer:

b. template<classT>.

Explanation:

Template functions are that can work with generic types. Template lets us to create a function so that more than 1 type or class can adapt  the functionality of that function.

We can write the template function as following:-

template<class typename>.

It matches to the option b.

5 0
2 years ago
Why does Brainly not have a astronomy section. (I'd prefer brainly answer this)
elena55 [62]
Could you by any chance help me with my business work?! Please go to my profile and go to the questions that have the subject business!
6 0
2 years ago
_____ is an information-analysis tool that involves the automated discovery of patterns and relationships in a data warehouse.
Tema [17]
Data mining is an information analysis tool that involves the automated discovery of patterns and relationship in the data warehouse.
<span />
7 0
3 years ago
Other questions:
  • How do you change brightness on acer laptop?
    7·1 answer
  • A Silicon Valley billionaire purchases 3 new cars for his collection at the end of every month. Let a_n denote the number of car
    8·1 answer
  • Ten members of a wedding party are lining up in a row for a photograph.
    8·1 answer
  • The instructions for a computer program are sometimes referred to as . computer programmers focus on computer programs, but they
    5·2 answers
  • which of the following statements about matter is true a.matter is anything that occupies space and possesses mass b.matter can
    5·2 answers
  • Plz help fast! will mark brainliest!<br><br>List three ways that music is used in modern society.
    6·1 answer
  • Which type of boot authentciation is more secure?
    10·1 answer
  • Which important aspect of the Roman Empire did the barbarians destroy?
    14·2 answers
  • Can someone please help me with this ,it is my assignment of technology and agriculture year 8
    5·1 answer
  • 2+2? D: I don't knoww​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!