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

Reputation: 2 Apprentice
Group:
Active Members
Active Posts:
95 (0.15 per day)
Joined:
19-October 12
Profile Views:
444
Last Active:
User is offline Jan 29 2014 03:37 PM
Currently:
Offline

Previous Fields

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

Posts I've Made

  1. In Topic: error with class object

    Posted 21 Oct 2013

    Yeah I see, sorry. What I meant was how exactly do I assign the data that the user would input into the class? I am trying to do that here:

    // Ask the user for pet data.
    28
            System.out.println("Enter the name of your pet: ");
    29
            pName = keyboard.nextLine();
    30
            pet.setName(pName); // here
    31
     
    32
            System.out.println("Enter the type of your pet: ");
    33
            pType = keyboard.nextLine();
    34
            pet.setType(pType); // here
    35
     
    36
            System.out.println("Enter the age of your pet: ");
    37
            pAge = keyboard.nextInt(); // and here
    38
            pet.setAge(pAge);
    
  2. In Topic: error with class object

    Posted 21 Oct 2013

    I tried initializing it at a later point, but I don't think I was writing it correctly. I tried something like pet.PetClass(pName, pType, pAge) and just got more errors...

    How does a default constructor work? Does it have the same purpose as a regular constructor?
  3. In Topic: error with class object

    Posted 21 Oct 2013

    I agree with you by naming it "Pet" rather than "PetClass" but we are required to name the files by Class and Demo so the teacher can understand the files we send to her.

    I realized how to initialize the class like that before, but I need to put data in from the user from the keyboard, so if I initialized it, it would be doing the assignment wrong. :/
  4. 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. //
    	////////////////////////
    }
    
  5. 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.

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?