Customers plan

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
//using bloodshed dev c++ compiler
//How can I output the name and a two digit number next to it
//example would be Indiana Jones 20
#include<iostream>
#include<string>

using namespace std;


class Customer
	{
		protected:
			string name; 
			string  min;
		public: 
		
			
			Customer()
			{
				setName("");
				
			
			}
			
		
			Customer(string cName)
			{
				setName(cName);
				
			}
			
		
			void setName(string cName)
			{
				name = cName;
				
				
				
			}
			string getName()
			{
				return name;
			}
		    
		
	};
class Premium:public Customer
	{
		protected:
			
			
		public:
		  Premium(string pname):Customer(pname)
		  {
		  	
		  }	
		
	};
	
	
	int main()
	{
		
		
		const int NUM_PEOPLE = 6;
		Customer *arr[NUM_PEOPLE] = 
		  {
		  	new Premium("Indiana Jones"),
		  	new Customer("James Kirt"),
		  	new Premium("Kacey Musgraves"),
		  	new Premium("John Stewart"),
		  	new Customer("Kaley Cuoco"),
		  	new Premium("Carrot Sticks")
		  	
		  };
		  for(int k = 0; k < NUM_PEOPLE;k++)
		  {
		  	cout<<" Customer "<< arr[k]->getName()
			    << endl;
		  }
		  return 1;
	}


	
Last edited on
Sorry, when you say Dev-C++, is this Bloodshed Dev-C++ or Orwell Dev-C++?

@Question: Depends on what this two-digit number represents. Generally, though you could just add a few more <<s to your statement on line 78 to print that number (with an additional "0" before it if the number is less than 10).

-Albatross

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
//almost got this code working the output shows a floating number on array //Kacey,John,and carrot and should be a two digit number
// 
#include<iostream>
#include<string>

using namespace std;


class Customer
	{
		protected:
			string name; 
			int numCalls;
		public: 
			Customer(string N, int c);
			virtual ~Customer();
			
		
			void set_values(string N, int C)
			{
				name = N; 
				numCalls = C;
			}
			string getName()
			{
				return name;
			}
			virtual float Compute_Bill()
			{
				return (10 + (.5 * numCalls));
			}
			
	};
class Premium:public Customer
	{
		protected:
			
			
		public:
			int x;
		    Premium(string N, int C):Customer (N,C)
		    {
		    	name = N;
		    	numCalls = C;
		    }
		    virtual ~Premium();
		    
		 
		    }
		    float Compute_Bill()
		    {
		    	return (20 + (.5 * numCalls) + (.1 * x));
		    }
		
	};
	Customer::Customer(string N, int C)
	{
		name = N; 
		numCalls = C;
	}
	Customer::~Customer(){}

	Premium::~Premium(){}
	
	
	int main()
	{
			const int NUM_PEOPLE = 6;
		Customer *arr[NUM_PEOPLE] = 
		  {
		  	new Premium("Indiana Jones", 20),
		  	new Customer("James Kirt", 50),
		  	new Premium("Kacey Musgraves", 10),
		  	new Premium("John Stewart", 50),
		  	new Customer("Kaley Cuoco", 30),
		  	new Premium("Carrot Sticks", 100)
		  	
		  };
		  for(int k = 0; k < NUM_PEOPLE;k++)
		  {
		  	cout<<" Customer "<< arr[k]->getName()<< " owes "       <<arr[k]->Compute_Bill()<<
			  " Dollars. "<<endl;
			    
		  }
		  for(int k = 0; k < NUM_PEOPLE; k++)
		  {
		  	delete arr[k];
		  }
		  
		  return 1;
		
		
	}
	
1
2
3
4
5
6
7
8
if(num < 100)
{
    if(num < 10)
    {
        cout<< "0";
    }
    cout<< num;
}


easy peasy...
Topic archived. No new replies allowed.