All pastes #1346838 Raw Edit

[phear]crippler

public text v1 · immutable
#1346838 ·published 2009-02-25 14:40 UTC
rendered paste body
#include <iostream>
using namespace std;

double midPoint(double x1, double y1, double x2, double y2);
int main()   {
    cout << "This program will calculate the Midpoint segment" << endl;
    cout << "joining any two sets of real numbers" << endl;
    double x1, y1, x2, y2;
    char again;
    do {
        cout << "\nEnter the first set.\n";
        cout << "x = ";
        cin >> x1;
        cout << "y = ";
        cin >> y1;
        
        cout << "\nNow enter the second set.\n";
        cout << "x = ";
        cin >> x2;
        cout << "y = ";
        cin >> y2;
        
        cout << "\nThe Midpoint segment is: " << midPoint(x1, y1, x2, y2) << endl;
        
        cout << "\nWould you like to do another? (Y/N): ";
        cin >> again;
     } while (again == 'y' || again == 'Y');
     /* system(" pause "); */
     return 0; }
double midPoint(double x1 = 0, double y1 = 0, double x2 = 0, double y2 = 0)
{   return (y2 - y1) / (x2 - x1);   }