migsrzxadvent021's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
Members
Active Posts:
18 (0.03 per day)
Joined:
16-October 11
Profile Views:
279
Last Active:
User is offline Apr 11 2012 09:47 PM
Currently:
Offline

Previous Fields

Country:
PH
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Playstation
Your Car:
Who Cares
Dream Kudos:
0

Latest Visitors

No latest visitors to show

Icon   migsrzxadvent021 has not set their status

Posts I've Made

  1. In Topic: C Problem: Tax Project (Some errors detected)

    Posted 11 Dec 2011

    View Postjimblumberg, on 11 December 2011 - 11:49 AM, said:

    Check your spelling:

    float TotalException() {
          PersonalDeduction();
          AdditionalExcemption();
          total_excemption = personal_deduction + additional_excemption;
          return total_excemption;
    }
    
    float TaxableIncome() {
          TotalExcemption();
          tax_income = TaxPayer.Gross_Income - total_excemption;
          return tax_income;
    }
    


    Your function definition and function call names are not the same.

    Next time post the entire error message exactly as it appears in your development environment. These messages have important information embedded in them to aid in locating and fixing the problem. One of these items is the line number where the error was detected.

    Also main() should be defined as returning an int, int main().


    Jim

    I would like to thank you very much for giving me such help Jim! And I altered some of the code to get the program running right too! Thanks a bunch! 'Til next programming...
  2. In Topic: C Problem: Tax Project (Some errors detected)

    Posted 11 Dec 2011

    View Postjimblumberg, on 11 December 2011 - 09:54 AM, said:

    If you need help on your remaining issues, post the modified code along with the complete error messages, exactly as they appear in your development environment. Remember these messages have important information embedded within them to aid in locating and fixing the problems.


    Jim


    Jim, here's my modified code I told you with the missing indent and with the Linker error and the exit status return error according to the Dev C++ compiler:
    #include <stdio.h>
    #include <stdlib.h>
    
    //Data structure for the taxpayer details
    typedef struct {
            char Name[100];
            int TIN;
            float Gross_Income;
            char Civil_Status[50];
            int dependents;
    } Tax;
    Tax TaxPayer; //This data structure contains four Tax payers
    
    //Global variables
    float tax_income, personal_deduction, additional_excemption, total_excemption, tax_due;
    
    //Global functions
    float PersonalDeduction();
    float AdditionalExcemption();
    float TotalException();
    float TaxableIncome();
    float TaxDue();
    
    //All floating integers shown here are in the Philippine Peso currency
    
    main() {
           char command;
           int ch; //variable as a part of a small while loop
           
           do {
               printf("\nDo you wish to pay your taxes? [Y]es or [N]o\n");
               command = getche();
               switch (toupper(command)) {
                      case ('Y'):
                           printf("Please put your name: ");
                           scanf("%s", TaxPayer.Name);
                           //this while loop stops the conflict between integer and string inputs
                           while ((ch = getchar()) != '\n' && ch != EOF);
                           printf("Please enter your TIN: ");
                           scanf("%i", &TaxPayer.TIN);
                           printf("Please enter your Gross Income: ");
                           scanf("%f", &TaxPayer.Gross_Income);
                           while ((ch = getchar()) != '\n' && ch != EOF);
                           printf("Select your civil/martial status (please exactly type in one of these): ");
                           printf("Single?\tMarried?\tFamily Head?\n");
                           scanf("%s", TaxPayer.Civil_Status);
                           while ((ch = getchar()) != '\n' && ch != EOF);
                           if (TaxPayer.Civil_Status != "single") {
                              printf("Please enter how many dependants you have: ");
                              scanf("%i", &TaxPayer.dependents);
                              if (TaxPayer.dependents > 4) {
                              printf("WARNING: too much dependents; only a maximum of four please!\n");
                              }
                           while ((ch = getchar()) != '\n' && ch != EOF);
                           }
                           else if (TaxPayer.Civil_Status == "single") {
                                TaxPayer.dependents = 0; //If the taxpayer is single, then there are no dependents
                           }
                           else {
                                printf("Unrecognizable civil status input! Leaving...\n");
                           }
                           
                           printf("Taxpayer name: %s\n", TaxPayer.Name);
                           printf("TIN: %i\n", TaxPayer.TIN);
                           printf("Gross income: %f\n", TaxPayer.Gross_Income);
                           printf("Civil Status: %s", TaxPayer.Civil_Status);
                           if (TaxPayer.Civil_Status != "single")
                              printf("Number of dependents: %i\n", TaxPayer.dependents);
                           else if (TaxPayer.Civil_Status == "single")
                           printf("No dependents...\n");
           
                           TaxableIncome();
                           printf("Your taxable income is %f\n", tax_income);
           
                           TaxDue();
                           printf("Your tax due is %f\n", tax_due);
                           
                           break;
                           
                      case ('N'):
                           break;
                      
                      default:
                              printf("You should only answer either a yes or a no, since this is a yes-or-no question!!\n");
                      }               
           } while(toupper(command) != 'N');
           
           printf("\n");
           system("pause");
    }
    
    float PersonalDeduction() {
          if (TaxPayer.Civil_Status == "single")
             personal_deduction = 20000.00;
           else if (TaxPayer.Civil_Status == "head of family" || TaxPayer.Civil_Status == "family head")
                personal_deduction = 25000.00;
           else if (TaxPayer.Civil_Status == "married")
                personal_deduction = 32000.00;
           return personal_deduction;
    }
    
    float AdditionalExcemption() {
          additional_excemption = TaxPayer.dependents * 8000.00;
          return additional_excemption;
    }
    
    float TotalException() {
          PersonalDeduction();
          AdditionalExcemption();
          total_excemption = personal_deduction + additional_excemption;
          return total_excemption;
    }
    
    float TaxableIncome() {
          TotalExcemption();
          tax_income = TaxPayer.Gross_Income - total_excemption;
          return tax_income;
    }
    
    float TaxDue() {
          TaxableIncome();
          if (tax_income <= 2500.00) {tax_due = 0.0;}
          else if (tax_income > 2500.00 && tax_income <= 5000.00) {tax_due = 1.0;}
          else if (tax_income > 5000.00 && tax_income <= 10000.00) {tax_due = (25.00 + (tax_income * 1.03)) / 5000.00;}
          else if (tax_income > 10000.00 && tax_income <= 20000.00) {tax_due = (175.00 + (tax_income * 1.07)) / 10000.00;}
          else if (tax_income > 20000.00 && tax_income <= 40000.00) {tax_due = (875.00 + (tax_income * 1.11)) / 20000.00;}
          else if (tax_income > 40000.00 && tax_income <= 60000.00) {tax_due = (3075.00 + (tax_income * 1.15)) / 40000.00;}
          else if (tax_income > 60000.00 && tax_income <= 100000.00) {tax_due = (6075.00 + (tax_income * 1.19)) / 60000.00;}
          else if (tax_income > 100000.00) {tax_due = (13675.00 + (tax_income * 0.24)) / 100000.00;}
          return tax_due;
    }
    
    


    View PostJackOfAllTrades, on 11 December 2011 - 09:55 AM, said:

    Check your spelling.


    I did. The compiler shows no errors for undeclared variables.
  3. In Topic: C Problem: Tax Project (Some errors detected)

    Posted 11 Dec 2011

    I got it Jim! Thanks! It was in my switch case loop. Fixed it! It's a programmer's most common mistake when it comes to PLs like C.

    Now the only errors I got are a Linker error, which is an undefined reference to the TotalExcemption function, and "Id returned exit status" error.
  4. In Topic: Display Problem

    Posted 10 Dec 2011

    View Postsk1v3r, on 10 December 2011 - 02:04 AM, said:

    If you divide an int by another int which is bigger, you will always get zero, because they cannot hold floating point numbers.
    You need to typecast one of the variables in the division t0 a float, for example:
    int a = 10;
    int b = 20;
    int c = a / b; // this will be zero
    float d = (float)a / b; // this will be 0.5
    //you can typecast either of the integers
    float e = a / (float)b;
    
    


    Thanks! I got the logic of what you mean! Now my program ran smoothly as I foreseen! So I put it here in the PercentOfTotal function:

    a_percentage = (candidate_a_total / (float) total_vote_cast) * 100;
    b_percentage = (candidate_b_total / (float) total_vote_cast) * 100;
    c_percentage = (candidate_c_total / (float) total_vote_cast) * 100;
    d_percentage = (candidate_d_total / (float) total_vote_cast) * 100;
    


    Plus, I was able to fix the output message about if any two of the four candidates got the most votes below 50%.

    Thanks a bunch skiver (Yeah, I can read leet!)!
  5. In Topic: Data Struct Problem in C

    Posted 23 Nov 2011

    View Postr.stiltskin, on 22 November 2011 - 11:46 PM, said:

    Delete the keyword typedef from line 7. If you use typedef, then STUDENT is a typename, and there is no declaration of an array of type STUDENT. Without the typedef, STUDENT is the name of an array of structs.

    Also, on line 23, insert int as the return type of main. main should always return a value, and you should state that explicitly.

    Thanks r.stiltskin; it worked, but the typedef definition is required for my class activity, so I'll have to save that file with your suggestion as another file in a .c file.

    However, the output (using the function displayAllStudentsGWA) where only students had a GWA of 85 and above isn't working...

My Information

Member Title:
New D.I.C Head
Age:
26 years old
Birthday:
January 21, 1987
Gender:
Location:
Quezon City, Metro Manila
Interests:
Gaming
Game Development (most particularly in game design)
Full Name:
Migs Rebueno
Years Programming:
5
Programming Languages:
PLs:
C, C++, C#, Java
Web:
HTML, PHP

Contact Information

E-mail:
Click here to e-mail me
Yahoo:
Yahoo  migreb2004
Facebook:
http://www.facebook.com/migsrzxadvent021
Twitter:
http://twitter.com/#!/migsrzxadvent21

Friends

migsrzxadvent021 hasn't added any friends yet.

Comments

migsrzxadvent021 has no profile comments yet. Why not say hello?