princludeciostream> includecfstream> includeciomanip> using namespace std; gint main() int n; cout « "Enter the number of cities" <« endl; cin >> n; Graph g(n); string city, temp; string c; int a; int i = 0; getline(cin, temp); while (i < n) cout « "Enter a city" << endl; getline(cin, city); cout « "How many adjacent cities it has" << end%; cin >> a; getline(cin, temp); while (a > e) cout « "Enter adjacent city" « endl; getline(cin, c); if (c =- "Seattle") g - addEdge(1, ®); else if (c -- "Chicago") g. addEdge(i, 1); else if (c -- "Los Angeles"). g. addEdge(1, 2); else if (c *- "Nashville") g- addEdge (1, 3); else if (c -- "Columbus") g. addEdge(i, 4); else if (c = "New York") g- addEdge (1, 5); else if (c *- "Austin") g. addEdge(i, 6); else if (c = "Atlanta") g. addEdge(i, 7); a-- i++;

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Can anybody understand why I have errors for 'graph' and 'getline'? and how should I fix it in order for the code to work?

O#include<iostream>
#include<fstream>
#includeciomanip>
using namespace std;
pint main()
int n;
cout « "Enter the number of cities" <« endl;
cin >> n;
Graph g(n);
string city, temp;
string c;
int a;
int i = 0;
getline (cin, temp);
while (i < n)
{
cout « "Enter a city" « endl;
getline(cin, city);
cout « "How many adjacent cities it has" <« endl;
cin >> a;
getline(cin, temp);
while (a > 0)
cout <« "Enter adjacent city" <« endl;
getline(cin, c);
if (c == "Seattle")
g. addEdge (i, 0);
else if (c == "Chicago")
g. addEdge (i, 1);
else if (c =- "Los Angeles")
g. addEdge (i, 2);
else if (c == "Nashville")
g. addEdge (i, 3);
else if (c == "Columbus")
g. addEdge (i, 4);
else if (c == "New York")
g. addEdge (1, 5);
else if (c == "Austin")
g. addEdge (i, 6);
else if (c == "Atlanta")
g. addEdge (i, 7);
a--;
i++;
g.display();
Transcribed Image Text:O#include<iostream> #include<fstream> #includeciomanip> using namespace std; pint main() int n; cout « "Enter the number of cities" <« endl; cin >> n; Graph g(n); string city, temp; string c; int a; int i = 0; getline (cin, temp); while (i < n) { cout « "Enter a city" « endl; getline(cin, city); cout « "How many adjacent cities it has" <« endl; cin >> a; getline(cin, temp); while (a > 0) cout <« "Enter adjacent city" <« endl; getline(cin, c); if (c == "Seattle") g. addEdge (i, 0); else if (c == "Chicago") g. addEdge (i, 1); else if (c =- "Los Angeles") g. addEdge (i, 2); else if (c == "Nashville") g. addEdge (i, 3); else if (c == "Columbus") g. addEdge (i, 4); else if (c == "New York") g. addEdge (1, 5); else if (c == "Austin") g. addEdge (i, 6); else if (c == "Atlanta") g. addEdge (i, 7); a--; i++; g.display();
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY