Help with class array output

Sep 24, 2016 at 4:35pm
Here's what i got

main file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include<iostream>
#include "elements.h"
using namespace std;
int main( )
{
	int StrgAmt;
	int number;
	Data bo[10];

	cout<<"How many elements do you want? : "<<endl;
	cin>>StrgAmt;

	for(int i=0;i<StrgAmt;i++){
		cout<<"Fill in the array: "<<endl;
		cin>>number;
		
	}
	for(int j=0;j<StrgAmt;j++){
		bo[j].setItem(number,StrgAmt);
		cout<<bo[j].getItem();
	}

	return 0;
}


elements.h
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
#ifndef _Data_BOX
#define _Data_BOX

// Set the type of data stored in the box
typedef double ItemType;

// Declaration for the class PlainBox
class Data
{
  private:
// Data field
  static const int Default_Size=10;
  ItemType vStore[Default_Size];
  int capacity; 
  int num_used;
  public:
// Default constructor
	Data ();
	bool isFull();
	bool isEmpty();
	int arrayCapacity();
	int numUsed(const ItemType& Entry);
	Data (const ItemType&  Entry);
	void setItem (const ItemType& Entry, int num_used);
	ItemType getItem () const;
	int ADD(const ItemType& Entry);
	int PosOfElem(const ItemType& Entry);

};  
#endif  


elements.cpp
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
#include "elements.h"

Data::Data ()
{
	capacity=10;
	  num_used=0;
}   // end default constructor

Data::Data (const ItemType& Entry){ }   // end constructor

bool Data::isFull(){return 0;}
bool Data::isEmpty(){return num_used==0;}
int Data::arrayCapacity(){return capacity;}
int Data::numUsed(const ItemType& Entry){return 0;}
void Data::setItem (const ItemType& Entry, int num_used){
	vStore[num_used]=Entry;
}  

ItemType Data::getItem() const{
  return vStore[num_used];
}  
int Data::ADD(const ItemType& Entry){
	bool ExtraRoom= (num_used < capacity);
	if (ExtraRoom){
		vStore[num_used] = Entry;
		num_used++;
	}
	return ExtraRoom;
}
int Data::PosOfElem(const ItemType& Entry){return 0;}


I keep getting numbers in exponential form in the output when i try to print it all out. How to fix it? thanks for taking time out to help.
Sep 24, 2016 at 4:57pm
Sep 24, 2016 at 5:23pm
It still doesnt work, what im trying to do is add elements to an array using the set function, then printing them out using the get function but i keep getting the same exponent number every time i print out the array
Sep 25, 2016 at 1:18am
How did you used the setprecision()?
Topic archived. No new replies allowed.