Calling a function in C++.NET
-
I need help folks,me and a couple of my friends spent the better part of 14 hours trying to figure out this code.The object of the code is to find a person's socioeconomic class based on their income.We are using functions for this but the problem is that when i run the program,the console prompts me for income after it has displayed the other information.Below is the code attached please if a good samaritan can look at this code and tell me what i can do to fix it.Thank you. include "stdafx.h" #using #include using namespace System; // Prototype for Functions String *GetFirstName(void); String *GetLastName(void); String *GetSocSecNum(void); String *GetGender(void); int GetAge(void); double GetIncome(void); void DisplayOutput(String*, String*, String*, String*, int); //This is the entry point for this application int _tmain(void) { //Declaration of Variables String *FName; String *LName; String *SSN; String *Gender; double Income; int Age; wchar_t Next; do { FName = GetFirstName(); LName = GetLastName(); SSN = GetSocSecNum(); Gender = GetGender(); Age =GetAge(); DisplayOutput(FName, LName, SSN, Gender, Age); Income = GetIncome(); //Request to do another individual Console::Write(S"\n\nWould you like to process another Individual(y/n): "); Next=Char::Parse(Console::ReadLine()); }while (Next=='y' || Next=='Y'); if (Next=='n' || Next=='N') //Printout of Information Console::WriteLine(S"\nGood Bye"); return 0; } //Functions: //Prompt User for First Name String *GetFirstName(void) { Console::Write(S"\nEnter the Individual's First Name: "); String *FName=Console::ReadLine(); return FName; } //Prompt User for Last Name String *GetLastName(void) { Console::Write(S"\nEnter the Individual's Last Name: "); String *LName=Console::ReadLine(); return LName; } //Prompt user for SSN String *GetSocSecNum(void) { Console::Write(S"\nEnter Social Security Number: "); String *SSN=(Console::ReadLine()); return SSN; } //Prompt User for Gender String *GetGender(void) { Console::Write(S"\nEnter the Gender: "); String *Gender=Console::ReadLine(); return Gender; } //Prompt user for Age int GetAge(void) { Console::Write(S"\nEnter Individual's Age: "); const int Age=Int32::Parse(Console::ReadLine()); return Age; } //Display Information void DisplayOutput(String *FName, String *LName, String
-
I need help folks,me and a couple of my friends spent the better part of 14 hours trying to figure out this code.The object of the code is to find a person's socioeconomic class based on their income.We are using functions for this but the problem is that when i run the program,the console prompts me for income after it has displayed the other information.Below is the code attached please if a good samaritan can look at this code and tell me what i can do to fix it.Thank you. include "stdafx.h" #using #include using namespace System; // Prototype for Functions String *GetFirstName(void); String *GetLastName(void); String *GetSocSecNum(void); String *GetGender(void); int GetAge(void); double GetIncome(void); void DisplayOutput(String*, String*, String*, String*, int); //This is the entry point for this application int _tmain(void) { //Declaration of Variables String *FName; String *LName; String *SSN; String *Gender; double Income; int Age; wchar_t Next; do { FName = GetFirstName(); LName = GetLastName(); SSN = GetSocSecNum(); Gender = GetGender(); Age =GetAge(); DisplayOutput(FName, LName, SSN, Gender, Age); Income = GetIncome(); //Request to do another individual Console::Write(S"\n\nWould you like to process another Individual(y/n): "); Next=Char::Parse(Console::ReadLine()); }while (Next=='y' || Next=='Y'); if (Next=='n' || Next=='N') //Printout of Information Console::WriteLine(S"\nGood Bye"); return 0; } //Functions: //Prompt User for First Name String *GetFirstName(void) { Console::Write(S"\nEnter the Individual's First Name: "); String *FName=Console::ReadLine(); return FName; } //Prompt User for Last Name String *GetLastName(void) { Console::Write(S"\nEnter the Individual's Last Name: "); String *LName=Console::ReadLine(); return LName; } //Prompt user for SSN String *GetSocSecNum(void) { Console::Write(S"\nEnter Social Security Number: "); String *SSN=(Console::ReadLine()); return SSN; } //Prompt User for Gender String *GetGender(void) { Console::Write(S"\nEnter the Gender: "); String *Gender=Console::ReadLine(); return Gender; } //Prompt user for Age int GetAge(void) { Console::Write(S"\nEnter Individual's Age: "); const int Age=Int32::Parse(Console::ReadLine()); return Age; } //Display Information void DisplayOutput(String *FName, String *LName, String
It is a matter od simply changing the order on which you call your functions. In your main method,
GetIncome()
should appear beforeDisplayOutput()
, not after. -
It is a matter od simply changing the order on which you call your functions. In your main method,
GetIncome()
should appear beforeDisplayOutput()
, not after.