randomchica
2011-03-18 00:39:27 UTC
A directly connected telephone network is one in which all telephones in the network are directly connected and do not require a central switching station to establish calls between two telephones. For example, financial institutions on Wall Street use such a network to maintain direct and continuously open phone lines between firms.
The number of direct lines needed to maintain a directly connected network for n telephone is given by the formula: lines = n(n − 1) / 2 For example, directly connecting four telephones requires 6 individual lines. Adding a fifth telephone to the network would require an additional 4 lines for a total of 10 lines.Using the given formula, write a C++ program that determines the number of direct lines required for as many telephones as the user of your program desires. You should test you program to determine the number of direct lines required for 100 telephones, and the number of lines required if 10 additional new telephones were added to the network (i.e., 110 telephones).
My program looks like this:
#include
using namespace std;
int main ()
{
double lines, n;
lines = n*(n-1)/2
cout << "Enter amount of telephones:";
cin >> n;
cout << lines << endl;
return 0;
}
Please help me with what I am doing wrong! My numerical answers are never correct and a debug error always pops up when I attempt to build the program.
Thank you so much!