4N63L-Z3R0's Profile User Rating: -----

Reputation: 2 Apprentice
Group:
Active Members
Active Posts:
91 (0.42 per day)
Joined:
19-October 12
Profile Views:
286
Last Active:
User is offline Apr 02 2013 11:29 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   4N63L-Z3R0 Learning. :]

Posts I've Made

  1. In Topic: Comparing array to an int

    Posted 2 Apr 2013

    incomeptr is an int pointer and avgincome is an int.

    Here is my program so far so you can see where I am at:
    // Midterm_Survey_N.cpp : Defines the entry point for the console application.
    
    // This program belongs to NM.
    #include "stdafx.h"
    #include <iostream>
    using namespace std;
    
    // Function prototypes.
    void incomeAvg (int *, int *, int);
    void poverty (int *, int *, int);
    // Function 3
    
    int main()
    {
    	const int SIZE = 13;
    	int id[SIZE];			// household id number - keep at 4 digits
    	int income[SIZE];		// household annual income
    	int memberNum[SIZE];	// household member number
    	int c;
    
    	// ***Assigned pointers*** ******************* //
    	int *idptr;
    	idptr = id;
    	
    	int *incomeptr;
    	incomeptr = income;
    
    	int *memberptr;
    	memberptr = memberNum;
    	// *********************** ****************** //
    
    	cout << "Enter 4-digit household ID number.\n";
    	for (c = 0; c < SIZE; c++)
    	{
    		cout << "Household " << (c+1) << ": ";
    		cin >> id[c];
    	}
    
    	cout << "\nEnter household's annual income.\n";
    	for (c = 0; c < SIZE; c++)
    	{
    		cout << "Household " << (c+1) << ": $";
    		cin >> income[c];
    	}
    
    	cout << "\nEnter number of members in household.\n";
    	for (c = 0; c < SIZE; c++)
    	{
    		cout << "Household " << (c+1) << ": ";
    		cin >> memberNum[c];
    	}
    
    	// Function calls.
    	incomeAvg (incomeptr, idptr, SIZE);
    	poverty (incomeptr, memberptr, SIZE);
    	// Function call 3
    
    	return 0;
    }
    
    // Function headers.
    void incomeAvg (int *incomeptr, int *idptr, int SIZE)
    {
    	int totalincome = 0, avgincome = 0;
    	int c;
    
    	// Total income (for average).
    	for (c = 0; c < SIZE; c++)
    	{
    		totalincome += incomeptr[c];
    	}
    
    	// Average income.
    	for (c = 0; c < SIZE; c++)
    	{
    		avgincome = totalincome / SIZE;
    	}
    
    	// Display the average income.
    	cout << "The average income between all households is: $" << avgincome << "." << endl;
    
    	// Display the EXCEEDING incomes.
    	cout << "-------Households that exceed the average income-------" << endl;
    	cout << "    Household ID        Exceeding Income";
    	////////////////////////
    	// More to come here. // This is where I am having the trouble.
    	////////////////////////
    
    	cout << endl;
    }
    
    void poverty (int *incomeptr, int *memberptr, int SIZE)
    {
    	double pov, percentage;
    	int c;
    
    	// Formula to calculate poverty line.
    	for (c = 0; c < SIZE; c++)
    	{
    		pov = 6500.00 + 750.00 * memberptr[c];
    	}
    
    	// Calculates percentage of households UNDER poverty line.
    	////////////////////////
    	// More to come here. //
    	////////////////////////
    }
    
  2. In Topic: Comparing array to an int

    Posted 2 Apr 2013

    I am trying to compare the numbers I have in the array to an average value. If there is a number, or multiple numbers, in the array that are greater than the average value then display those numbers.

    There are no errors notified by my compiler, but I am not getting the output I want. I am getting the actual coded value of incomeptr[c] which is a messy combination of numbers and letters. I need a list of the greater-than-average values in the array.
  3. In Topic: Most frequent character in string

    Posted 12 Mar 2013

    Aaahh! Yes!! Thank you very much! :D
    It is running perfectly now.

    As I said before, shouldn't program while tired... Hahaha!
  4. In Topic: Most frequent character in string

    Posted 12 Mar 2013

    Yeah, that makes sense! I shouldn't do this while tired, hah.

    I tried

    if (arr[string1[c]] > max && arr[string1[c]] != ' ')

    and am still having the same issue.
  5. In Topic: Most frequent character in string

    Posted 12 Mar 2013

    I noted that when I run this program, if I use a sentence like "Hello I am a moose" I get a blank as my most frequent character because the most frequent character is a space " ". I am fiddling with it to try and not count the spaces, but am having a hard time.

    How could I add that it doesn't count spaces?

    This isn't required for the assignment, I would just like to practice for personal skill.

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

4N63L-Z3R0 hasn't added any friends yet.

Comments

4N63L-Z3R0 has no profile comments yet. Why not say hello?