please correct the mistakes in my coding

Que Vodafone mobile company wants software to maintain the account of its Prepaid Customers.
Create a class PREPAID having the following attributes
1. Name_of_Owner
2. Sim_no
3. Mobile_no
4. Balance

On purchase of any new sim a new object of PREPAID class is to be made and values of the attributes
are to be allocated via parameterized constructor except balance
Class should have following methods
1. addBalance() ---------------------{With Parameter No Return type}
{Hint: This method will add the recharge amount to the current balance}
2. currentBalance() ------------------{No Parameter With Return type}
{Hint: This method will return the current balance}
3. balanceDeduction() -------------{With Parameter With Return type}
{Hint: This method will take duration of call in minutes only as parameter, reduce the balance by rate 50p per
minute and return the updated balance}
4. showInfo() -----------------------{No Parameter No Return type}
{Hint: This method will display all attributes}



My Code




#include<iostream.h>
#include<conio.h>

class Prepaid

{
private:
char name[];
long sim;
long mobil;
float bal,total,minute;
float current;
float recharge;
float min;
char n[10];
long s,mobi;


public:
void inf();
void addBalance();
float currentBalance();
float balanceDeduction();
void showInfo();

}
void Prepaid::inf(char n[],long s,long mobi)
{
name=n;
s=sim;
mobi=mobil;
}
void Prepaid::addBalance(recharge)
{
current = 20.0;
bal=recharge;
total=bal+current;

}
float Prepaid::currentBalance()
{
cout<<"current balance :"<<total;
return (total);
}
float Prepaid::balanceDeduction(min)
{
minute=min;
total=(total-(min*.5));
cout<<"your call was made of "<<minute<," and remaining balance:"<<total);
return (total);
}
void Prepaid::showInfo()
{
cout<<"name:"<<name;
cout<<"sim no:"<<sim;
cout<<"mobile no:"<<mobil;
cout<<"balance:"<<total;
}
}
void main()
{
clrscr();
Prepaid p;
p.inf("Sonu",1493,9303072070);
p.addBalance(400);
p.currentBalance();
p.balanceDeduction(14);
p.showInfo();
}
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
you dont have to create one class for the PrePaid

e.g

class Person
{
private : 
 	char name[50];
 	Person( ) { } 
 	Person( char* ch_name )  { strcpy( ch_name , name ) ; }  
 	
};
and according to your specification the class Prepaid will be

class Prepaid : public Person
{
private:
	long sim;
	long moblie_no;
	float curr_balance ; 
	float recharge;
public:
	Prepaid(char * ch_name, long m_mobile_no) : Person( ch_name ), moblie_no( m_moblie_no)  { } 
	void addBalance(float f_recharge);
	float currentBalance();
};
void Prepaid::addBalance(float f_recharge)
{
	curr_balalance += f_recharge;
}

float Prepaid::currentBalance()
{
	cout<<"current balance :"<<curr_balalance ;
	return (curr_balalance );
}

void Prepaid::showInfo()
{
	cout<<"name:"<<name;
	cout<<"sim no:"<<sim;
	cout<<"mobile no:"<<mobile_no;
	cout<<"balance:"<<c;
}



void main()
{
	clrscr();
	Prepaid p("Sonu",9303072070);
	p.addBalance(400);
	p.currentBalance();	
	p.showInfo();
}
giving following errors


Compiling VODAFONE.CPP:
Error VODAFONE.CPP 27: Too many types in declaration
Error VODAFONE.CPP 28: 'Prepaid::inf(char *,long,long)' is not a member of 'Prepaid'
Warning VODAFONE.CPP 33: Style of function definition is now obsolete
Warning VODAFONE.CPP 45: Style of function definition is now obsolete
Error VODAFONE.CPP 49: Expression syntax
Error VODAFONE.CPP 59: Unexpected }
Error VODAFONE.CPP 64: Extra parameter in call to Prepaid::inf()
Error VODAFONE.CPP 65: Extra parameter in call to Prepaid::addBalance()
Error VODAFONE.CPP 67: Extra parameter in call to Prepaid::balanceDeduction()
Topic archived. No new replies allowed.