Issue with exit(EXIT_FAILURE)

Hello, i have a issue within my code that does not allow my exit(EXIT_FAILURE) to work properly.

Aside from the exit failure, the program is supposed to gather information regarding prints from a gallery, 3 prints in total, with that being said, when ever i run the program and enter everything for the first print it exit's immediately and doesn't let me enter prints 2 and 3.

This is the Inventory.h file for the class functions and variables.
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
#ifndef INVENTORY_H_
#define INVENTORY_H_
#include <iostream>
#include <string>
#include "stdlib.h"
using namespace std;
//class defining the inventory
class Inventory
{
	private:
	// member variables
		int inventoryNumber;
		string imageName;
		string photogLastName;
		float pricePaid;
		float priceSell;
		int numberSold;


	public:
	//member functtions
		Inventory();
		Inventory(int inventoryNumber, string imageName, string photogLastName, float pricePaid, float priceSell, int numberSold);
		void setInventoryNumber(int inventoryNumber);
		void setImageName(string imageName);
		void setPhotogLastName(string photogLastName);
		void setPricePaid(float pricePaid);
		void setPriceSell(float priceSell);
		void setNumberSold(int numberSold);
		int getInventoryNumber();
		string getImageName();
		string getPhotogLastName();
		float getPricePaid();
		float getPriceSell();
		int getNumberSold();
};
#endif INVENTORY_H_ 


Here is the Inventory.cpp for the functions, which is where the exit(EXIT_FAILURE)'s are
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include "Inventory.h"
#include <iostream>
#include <cstdlib>
#include <iomanip>

using namespace std;

Inventory::Inventory(){
	inventoryNumber = 0;
	imageName = "";
	photogLastName = "";
	pricePaid = 0;
	priceSell = 0;
	numberSold = 0;
}


Inventory::Inventory(int inventoryNumber, string imageName, string photogLastName, float pricePaid, float priceSell, int numberSold){
	Inventory::inventoryNumber = inventoryNumber;
	Inventory::imageName = imageName;
	Inventory::photogLastName = photogLastName;
	Inventory::pricePaid = pricePaid;
	Inventory::priceSell = priceSell;
	Inventory::numberSold = numberSold;
}

void Inventory::setInventoryNumber(int inventoryNumber) {
	if (inventoryNumber < 0);{
		cout << "\n Inventory number cannt be less than 0.";
		exit(EXIT_FAILURE);
	}
	Inventory::inventoryNumber = inventoryNumber;
}

void Inventory::setImageName(string imageName) {
	if (imageName.length() > 25);{
		cout << "\n Length of Image name cannot be greater than 25 characters";
		exit(EXIT_FAILURE);
	}
	Inventory::imageName = imageName;
}

void Inventory::setPhotogLastName(string photogLastName) {
	if (photogLastName.length() > 25); {
		cout << "\n Length of last name of photographer cannot be greater than 25 characters.";
		exit(EXIT_FAILURE);
	}
	Inventory::photogLastName = photogLastName;
}
void Inventory::setNumberSold(int numberSold){
	if (numberSold < 0);{
		cout << "\n Number of prints sold cannt be less than 0.";
		exit(EXIT_FAILURE);
	}
	Inventory::numberSold = numberSold;
}

void Inventory::setPricePaid(float pricePaid){
	if (pricePaid < 0);{
		cout << "\n Price that gallery paid for the print cannot be less than 0.";
		exit(EXIT_FAILURE);
	}
	Inventory::pricePaid = pricePaid;
}

void Inventory::setPriceSell(float priceSell) {
	if (priceSell < 0);{
		cout << "\n Retail Price for the print cannot be less than 0.";
		exit(EXIT_FAILURE);
	}
	Inventory::priceSell = priceSell;
}

int Inventory::getInventoryNumber() {
	return inventoryNumber;
}

string Inventory::getImageName() {
	return imageName;
}

string Inventory::getPhotogLastName() {
	return photogLastName;
}
float Inventory::getPricePaid() {
	return pricePaid;
}

float Inventory::getPriceSell() {
	return priceSell;
}

int Inventory::getNumberSold() {
	return numberSold;
}

And here is my Main.cpp to gather the users input.
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
#include <iostream>
#include <limits>
#include <iomanip>
#include <cstdlib>
#include "Inventory.h"

using namespace std;

int main() {
	Inventory inventory[3];
	int inventoryNumber;
	string imageName;
	string photogLastName;
	float pricePaid;
	float priceSell;
	int numberSold;

	for (int i = 0; i < 3; i++) {
		cout << "\n Enter details of the Print " << (i + 1) << " : " << endl;
		cout << "\n Enter Inventory number: ";
		cin >> inventoryNumber;
		std::cin.ignore(std::numeric_limits < std::streamsize >::max(), '\n');
		cout << "\n Enter image name: ";
		getline(cin, imageName);
		cout << "\n Enter Last Name of the photographer: ";
		getline(cin, photogLastName);
		cout << "\n Enter the price the gallery paid for the Print: $";
		cin >> pricePaid;
		cout << "\n Enter the retail price for the print: $";
		cin >> priceSell;
		cout << "\n Enter the number of prints sold to date: ";
		cin >> numberSold;
		inventory[i].setInventoryNumber(inventoryNumber);
		inventory[i].setImageName(imageName);
		inventory[i].setPhotogLastName(photogLastName);
		inventory[i].setPricePaid(pricePaid);
		inventory[i].setPriceSell(priceSell);
		inventory[i].setNumberSold(numberSold);
		std::cin.ignore(std::numeric_limits < std::streamsize >::max(), '\n');
	}

	for (int i = 0; i < 3; i++) {
		cout << "\n Inventory Number: " << inventory[i].getInventoryNumber() << endl;
		cout << "\n Image Name: " << inventory[i].getImageName().substr(0, inventory[i].getImageName().length() - 1);
		cout << "\n Photographer's Last Name: " << inventory[i].getPhotogLastName().substr(0, inventory[i].getPhotogLastName().length() - 1);
		cout << "\n Price Paid: $ " << fixed << setprecision(2) << inventory[i].getPricePaid();
		cout << "\n Retail Price: $ " << fixed << setprecision(2) << inventory[i].getPriceSell();
		cout << "\n Number of Prints Sold: " << inventory[i].getNumberSold();
	}
	return 0;

}
What does work properly mean regarding exit(EXIT_FAILURE)? It will end your program immediately.
Topic archived. No new replies allowed.