Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Calling a function in C++.NET

Calling a function in C++.NET

Scheduled Pinned Locked Moved .NET (Core and Framework)
helpcsharpc++securitylounge
3 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    benibo
    wrote on last edited by
    #1

    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

    A 1 Reply Last reply
    0
    • B benibo

      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

      A Offline
      A Offline
      apferreira
      wrote on last edited by
      #2

      It is a matter od simply changing the order on which you call your functions. In your main method, GetIncome() should appear before DisplayOutput(), not after.

      B 1 Reply Last reply
      0
      • A apferreira

        It is a matter od simply changing the order on which you call your functions. In your main method, GetIncome() should appear before DisplayOutput(), not after.

        B Offline
        B Offline
        benibo
        wrote on last edited by
        #3

        I tried to do that but the thing is that the GetIncome() function that gets called reads a -1E and that is wromg because i want it to read the income in my IF statement.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups