Project on c++

I got stuck in C++ Programming . I'm not really good but wish to learn alot from several experts. I got a project. Title Patient Fees . which im not really sure how to end it.
And your project has what requirements? What needs to be done? Show us some of the code you've already made for this project.
yes show us the code which you have started .
This are actually part of the program by using class and object.

My intention is to enter ward first then enter type of ward but once i executed it, it allow me to enter ward but it jump to enter Days in hospital which is another functions below it. Advice please.......



void Charges::enterWardType()
{
cout<<"\nenter Ward: ";
cin>>Ward;

cout<<"\nEnter Type of Ward: ";
getline(cin,Type);

if (Ward == 'A' || Ward == 'a') //intitializing values to Ward A for 1 day charges.
{
if (Type == "Acute Ward" || Type == "acute ward")
{
Ward_fees = 230;
}
else if (Type == "Intensive Care unit" || Type == "acute ward")
{
Ward_fees = 500;
}
else if (Type == "Consultation" || Type == "consultation")
{
Ward_fees = 50;
}
else
{
Ward_fees = 0;
}

}
else if (Ward == 'B' || Ward == 'b') //intitializing values to Ward A for 1 day charges.
{
if (Type == "Acute Ward" || Type == "acute ward")
{
Ward_fees = 150;
}
else if (Type == "Intensive Care unit" || Type == "acute ward")
{
Ward_fees = 300;
}
else if (Type == "Consultation" || Type == "consultation")
{
Ward_fees = 40;
}
else
{
Ward_fees = 0;
}
}
else if (Ward == 'C' || Ward == 'c') //intitializing values to Ward A for 1 day charges.
{
if (Type == "Acute Ward" || Type == "acute ward")
{
Ward_fees = 75;
}
else if (Type == "Intensive Care unit" || Type == "acute ward")
{
Ward_fees = 150;
}
else if (Type == "Consultation" || Type == "consultation")
{
Ward_fees = 25;
}
else
{
Ward_fees = 0;
}
}

}
void Charges::enternumDays()
{
cout<<"\nEnter Days in Hospital: ";
cin>>numDays;
}
I hope in the future remarks like "Stupid assignment or homework" and other form of insult shouldnt have been typed inside the message. You can said it to yourself or being angry but dont typed inside. Have some respect to the newbies. ok! And to all expert all of you wasnt born smart or came out from your mother's womb with a notebook in your hand. All off you might be good at what you are but the other side of you might be totally lame... So Wake up!!!!!!!!! Believe in the word "Retribution"........................ Arios..........
!!??!! I doubt you'll be getting any more advice in the future.
closed account (S6k9GNh0)
Actually, I learned to be a programmer through pure hard work and devotion with a side of studying.

1) Type your message clearly.
2) Make sure to follow the standard for inserting code into the forum.
3) When you insert your code that is of the basic level and just so happens to be a homework assignment, that insults a common C++ hobbyist. This is because it means you don't give a crap to learn C++ and could care less, and instead, you chose to throw your problem onto those who do it daily instead of learning something yourself. In respect to that, a common C++ programmer could ask why he or she should have to help you. It's the same for any language, not just C++.
You need to add something in the beginning of your code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
void Charges::enterWardType()
{
cout<<"\nenter Ward: ";
cin>>Ward;

cin.get(); //<- add this here!

cout<<"\nEnter Type of Ward: ";
getline(cin,Type);

//...
//the rest of your function's code
//...
}


Tell me if this fixed the problem
Last edited on
Actually, tanks master roshi, my program already been fixed. i didnt put in cout<<fflush(stdin) before cout<<"\nEnter Type of Ward: ";.

But i will try it out your method. Thanks again.........

And for the rest of the programmers i'm terribly sorry if i have hurt their feelings but the person who has been hurl with other forms of disgusted abused also has feelings too. Just like me. I might be a new bies to all of you but getting calling names and and other "stupid" words is not my type of "codes"......... Have a nice day to all.........
To computerquip,

Thanks for your advice, i hope in the future i will learn alot from people like you. Thanks......
Topic archived. No new replies allowed.