For my beginner's C++ class my assignment is to create a library with following functions (prototypes are given along with a description):
1. void increasing (double& A, double& B, double& C); //Arranges A, B, and C in increasing order.
2. void decreasing (double& A, double& B, double& C); //Arranges A, B, and C in decreasing order.
3. void mmm (double& A, double& B, double& C); //Replaces A with the minimum of A, B, and C; replaces B with the average of
A, B, and C; replaces C with the maximum of A, B, and C.
Use the library in a program where the user is asked to enter three numbers. The program calls all three functions above and
outputs the new values of A, B, and C for each case. Do not just output numbers. Display a message with each result.*/
Jdog is my library name.
My header is
|
void increasing(double&A, double&B, double&C); /*Displays 3 numbers in increasing order*/
|
My .cpp is
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
void increasing(double&A, double&B, double&C)
{
double small, double medium, double large;
if ((A <= B) && (A <= C) && (B <= C))
{
small = A;
medium = B;
large = C;
}
if ((A <= B) && (A <= C) && (B >= C))
{
small = A;
medium = C;
large = B;
}
if ((A <= B) && (A >= C) && (B <= C))
{
small = B;
medium = A;
large = C;
}
if ((A >= B) && (A <= C) && (B <= C))
{
small = B;
medium = A;
large = C;
}
if ((A >= B) && (A >= C) && (B <= C))
{
small = B;
medium = C;
large = A;
}
if ((A >= B) && (A <= C) && (B >= C))
{
small = C;
medium = A;
large = B;
}
if ((A >= B) && (A >= C) && (B >= C))
{
small = C;
medium = B;
large = A;
}
if ((A <= B) && (A >= C) && (B >= C))
{
small = A;
medium = B;
large = C;
}
if ((A <= B) && (A >= C) && (B >= C))
{
small = C;
medium = A;
large = B;
}
A = small;
B = medium;
C = large;
return;
}
|
My coding is
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
int main()
#include<iostream>
#include<cmath>
#include"Jdog.h"
{
using namespace std;
void increasing(double& A, double& B, double& C);
double A, double B, double C;
int small, int medium, int large;
cout << "Enter three numbers" << endl;
cin >> A >> B >> C;
A = small, B = medium, C = large;
cout << "Numbers in increasing order:" << void increasing(A, B, C) << small, meduim, large << endl;
return 0;
}
|
My issues:
-The "void increasing" in my cout is coming up as an error.
-I'm not understanding how to rearrange A,B and C in increasing order and subsequently decreasing order.
-Frankly I don't know how to get the last one.