User can't put full name with space in my C++ program [on hold]
up vote
-12
down vote
favorite
Here user can't type full name; if user enters a full name then the second part of name automatically becomes the 2nd choice. I don't know how to solve this.
And here is the program.
I am designing and implementing a class student_list having some requirements:
//Class
class std_list
{
public:
char *name;
int length;
char res_type;
int total;
//default
std_list()
{
length =20;
name=new char[length+1];
total=0;
}
~std_list()
{
delete name;
}
void accept();
void display();
void fee();
}; //End of Class
void std_list::fee()
{
if((res_type=='2')||(res_type=='2'))
{
total=5000 + 5000 + 2000;
}
else
{
total = 5000;
}
cout<<"Total ==> "<<total;
}
//fee end
void std_list::display()
{
cout<<"nnnn The Name of Student is t";
cout<<name;
cout<<"nnnn The Resident type is t";
cout<<res_type;
cout<<"nnnn Your Total fee t";
cout<<total;
getch();
}
//display end
void std_list::accept()
{
cout<<"Enter your Name => t";
cin>>name;
cout.flush();
cout<<"Choose resident type include room rent + Food cost + tution Fees==> 1200 nn" ;
cout<<"2 Non Resident include tutionfee fee Cost 5000n";
cout<<"Press 1 for residentn";
cout<<"press 2 for non residentn";
cin>>res_type;
if((res_type=='y')||(res_type=='Y'))
{
cout<<"nn You Choose Residential option so your chares are as";
cout<<"nYour Room Rent is 5000 t";
cout<<"nYour tuition fee is 5000 t";
cout<<"nYour food cost is 2000 t";
}
else
{
cout<<"nYour tuition fee is 5000 t";
}
}
int main()
{
std_list ob;
ob.accept();
ob.fee();
ob.display();
return 0;
getch();
}
This page contains examples on basic concepts of C++ programming like: loops, functions, pointers, structures etc.
In this comprehensive guide to C++ programming, you will be introduced to everything from C++ applications to running your first C++ program
Source code to display a sentence in C++ programming...
Here I will discuss all C++ basic programs in simple and easy way, here I will use C++ programming language for coding of any programs. Also I will discuss all ...
Write a program in C++ to print a massage on output screen.
#include <iostream>
using namespace std;
int main()
{
cout<<"Hello world";
return 0;
}
Output:
c++ class logic-programming
put on hold as unclear what you're asking by Jonathan Leffler, πάντα ῥεῖ, Sid S, gnat, Moritz Nov 18 at 10:20
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
up vote
-12
down vote
favorite
Here user can't type full name; if user enters a full name then the second part of name automatically becomes the 2nd choice. I don't know how to solve this.
And here is the program.
I am designing and implementing a class student_list having some requirements:
//Class
class std_list
{
public:
char *name;
int length;
char res_type;
int total;
//default
std_list()
{
length =20;
name=new char[length+1];
total=0;
}
~std_list()
{
delete name;
}
void accept();
void display();
void fee();
}; //End of Class
void std_list::fee()
{
if((res_type=='2')||(res_type=='2'))
{
total=5000 + 5000 + 2000;
}
else
{
total = 5000;
}
cout<<"Total ==> "<<total;
}
//fee end
void std_list::display()
{
cout<<"nnnn The Name of Student is t";
cout<<name;
cout<<"nnnn The Resident type is t";
cout<<res_type;
cout<<"nnnn Your Total fee t";
cout<<total;
getch();
}
//display end
void std_list::accept()
{
cout<<"Enter your Name => t";
cin>>name;
cout.flush();
cout<<"Choose resident type include room rent + Food cost + tution Fees==> 1200 nn" ;
cout<<"2 Non Resident include tutionfee fee Cost 5000n";
cout<<"Press 1 for residentn";
cout<<"press 2 for non residentn";
cin>>res_type;
if((res_type=='y')||(res_type=='Y'))
{
cout<<"nn You Choose Residential option so your chares are as";
cout<<"nYour Room Rent is 5000 t";
cout<<"nYour tuition fee is 5000 t";
cout<<"nYour food cost is 2000 t";
}
else
{
cout<<"nYour tuition fee is 5000 t";
}
}
int main()
{
std_list ob;
ob.accept();
ob.fee();
ob.display();
return 0;
getch();
}
This page contains examples on basic concepts of C++ programming like: loops, functions, pointers, structures etc.
In this comprehensive guide to C++ programming, you will be introduced to everything from C++ applications to running your first C++ program
Source code to display a sentence in C++ programming...
Here I will discuss all C++ basic programs in simple and easy way, here I will use C++ programming language for coding of any programs. Also I will discuss all ...
Write a program in C++ to print a massage on output screen.
#include <iostream>
using namespace std;
int main()
{
cout<<"Hello world";
return 0;
}
Output:
c++ class logic-programming
put on hold as unclear what you're asking by Jonathan Leffler, πάντα ῥεῖ, Sid S, gnat, Moritz Nov 18 at 10:20
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
2
Usestd::string
to store strings. Usestd::getline()
to input strings containing spaces.
– Sid S
Nov 18 at 2:48
2
The tail end of your question (from "This page contains examples on basic concepts of C++ programming" onwards) seems to be unrelated to the material at the start. None of it is C; do not abuse the C tag.
– Jonathan Leffler
Nov 18 at 2:50
2
Possible duplicate of std::cin input with spaces?
– Little Boy Blue
Nov 18 at 4:52
add a comment |
up vote
-12
down vote
favorite
up vote
-12
down vote
favorite
Here user can't type full name; if user enters a full name then the second part of name automatically becomes the 2nd choice. I don't know how to solve this.
And here is the program.
I am designing and implementing a class student_list having some requirements:
//Class
class std_list
{
public:
char *name;
int length;
char res_type;
int total;
//default
std_list()
{
length =20;
name=new char[length+1];
total=0;
}
~std_list()
{
delete name;
}
void accept();
void display();
void fee();
}; //End of Class
void std_list::fee()
{
if((res_type=='2')||(res_type=='2'))
{
total=5000 + 5000 + 2000;
}
else
{
total = 5000;
}
cout<<"Total ==> "<<total;
}
//fee end
void std_list::display()
{
cout<<"nnnn The Name of Student is t";
cout<<name;
cout<<"nnnn The Resident type is t";
cout<<res_type;
cout<<"nnnn Your Total fee t";
cout<<total;
getch();
}
//display end
void std_list::accept()
{
cout<<"Enter your Name => t";
cin>>name;
cout.flush();
cout<<"Choose resident type include room rent + Food cost + tution Fees==> 1200 nn" ;
cout<<"2 Non Resident include tutionfee fee Cost 5000n";
cout<<"Press 1 for residentn";
cout<<"press 2 for non residentn";
cin>>res_type;
if((res_type=='y')||(res_type=='Y'))
{
cout<<"nn You Choose Residential option so your chares are as";
cout<<"nYour Room Rent is 5000 t";
cout<<"nYour tuition fee is 5000 t";
cout<<"nYour food cost is 2000 t";
}
else
{
cout<<"nYour tuition fee is 5000 t";
}
}
int main()
{
std_list ob;
ob.accept();
ob.fee();
ob.display();
return 0;
getch();
}
This page contains examples on basic concepts of C++ programming like: loops, functions, pointers, structures etc.
In this comprehensive guide to C++ programming, you will be introduced to everything from C++ applications to running your first C++ program
Source code to display a sentence in C++ programming...
Here I will discuss all C++ basic programs in simple and easy way, here I will use C++ programming language for coding of any programs. Also I will discuss all ...
Write a program in C++ to print a massage on output screen.
#include <iostream>
using namespace std;
int main()
{
cout<<"Hello world";
return 0;
}
Output:
c++ class logic-programming
Here user can't type full name; if user enters a full name then the second part of name automatically becomes the 2nd choice. I don't know how to solve this.
And here is the program.
I am designing and implementing a class student_list having some requirements:
//Class
class std_list
{
public:
char *name;
int length;
char res_type;
int total;
//default
std_list()
{
length =20;
name=new char[length+1];
total=0;
}
~std_list()
{
delete name;
}
void accept();
void display();
void fee();
}; //End of Class
void std_list::fee()
{
if((res_type=='2')||(res_type=='2'))
{
total=5000 + 5000 + 2000;
}
else
{
total = 5000;
}
cout<<"Total ==> "<<total;
}
//fee end
void std_list::display()
{
cout<<"nnnn The Name of Student is t";
cout<<name;
cout<<"nnnn The Resident type is t";
cout<<res_type;
cout<<"nnnn Your Total fee t";
cout<<total;
getch();
}
//display end
void std_list::accept()
{
cout<<"Enter your Name => t";
cin>>name;
cout.flush();
cout<<"Choose resident type include room rent + Food cost + tution Fees==> 1200 nn" ;
cout<<"2 Non Resident include tutionfee fee Cost 5000n";
cout<<"Press 1 for residentn";
cout<<"press 2 for non residentn";
cin>>res_type;
if((res_type=='y')||(res_type=='Y'))
{
cout<<"nn You Choose Residential option so your chares are as";
cout<<"nYour Room Rent is 5000 t";
cout<<"nYour tuition fee is 5000 t";
cout<<"nYour food cost is 2000 t";
}
else
{
cout<<"nYour tuition fee is 5000 t";
}
}
int main()
{
std_list ob;
ob.accept();
ob.fee();
ob.display();
return 0;
getch();
}
This page contains examples on basic concepts of C++ programming like: loops, functions, pointers, structures etc.
In this comprehensive guide to C++ programming, you will be introduced to everything from C++ applications to running your first C++ program
Source code to display a sentence in C++ programming...
Here I will discuss all C++ basic programs in simple and easy way, here I will use C++ programming language for coding of any programs. Also I will discuss all ...
Write a program in C++ to print a massage on output screen.
#include <iostream>
using namespace std;
int main()
{
cout<<"Hello world";
return 0;
}
Output:
c++ class logic-programming
c++ class logic-programming
edited Nov 18 at 2:50
Jonathan Leffler
554k886591012
554k886591012
asked Nov 18 at 2:38
Anoop Seth
11
11
put on hold as unclear what you're asking by Jonathan Leffler, πάντα ῥεῖ, Sid S, gnat, Moritz Nov 18 at 10:20
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
put on hold as unclear what you're asking by Jonathan Leffler, πάντα ῥεῖ, Sid S, gnat, Moritz Nov 18 at 10:20
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
2
Usestd::string
to store strings. Usestd::getline()
to input strings containing spaces.
– Sid S
Nov 18 at 2:48
2
The tail end of your question (from "This page contains examples on basic concepts of C++ programming" onwards) seems to be unrelated to the material at the start. None of it is C; do not abuse the C tag.
– Jonathan Leffler
Nov 18 at 2:50
2
Possible duplicate of std::cin input with spaces?
– Little Boy Blue
Nov 18 at 4:52
add a comment |
2
Usestd::string
to store strings. Usestd::getline()
to input strings containing spaces.
– Sid S
Nov 18 at 2:48
2
The tail end of your question (from "This page contains examples on basic concepts of C++ programming" onwards) seems to be unrelated to the material at the start. None of it is C; do not abuse the C tag.
– Jonathan Leffler
Nov 18 at 2:50
2
Possible duplicate of std::cin input with spaces?
– Little Boy Blue
Nov 18 at 4:52
2
2
Use
std::string
to store strings. Use std::getline()
to input strings containing spaces.– Sid S
Nov 18 at 2:48
Use
std::string
to store strings. Use std::getline()
to input strings containing spaces.– Sid S
Nov 18 at 2:48
2
2
The tail end of your question (from "This page contains examples on basic concepts of C++ programming" onwards) seems to be unrelated to the material at the start. None of it is C; do not abuse the C tag.
– Jonathan Leffler
Nov 18 at 2:50
The tail end of your question (from "This page contains examples on basic concepts of C++ programming" onwards) seems to be unrelated to the material at the start. None of it is C; do not abuse the C tag.
– Jonathan Leffler
Nov 18 at 2:50
2
2
Possible duplicate of std::cin input with spaces?
– Little Boy Blue
Nov 18 at 4:52
Possible duplicate of std::cin input with spaces?
– Little Boy Blue
Nov 18 at 4:52
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
2
Use
std::string
to store strings. Usestd::getline()
to input strings containing spaces.– Sid S
Nov 18 at 2:48
2
The tail end of your question (from "This page contains examples on basic concepts of C++ programming" onwards) seems to be unrelated to the material at the start. None of it is C; do not abuse the C tag.
– Jonathan Leffler
Nov 18 at 2:50
2
Possible duplicate of std::cin input with spaces?
– Little Boy Blue
Nov 18 at 4:52