nkhosinathie 0 Light Poster

my problem for introducing hetrosexual is to calculate the people above 32, so how can i do that if hetrosexual is ignored

nkhosinathie 0 Light Poster

so lets say inthe gender i add heterosexual because i want to calculate the people above 32 where gender male or female doesn't matter,so will it not give me some errors

nkhosinathie 0 Light Poster

Here's a skeleton form for how to do this with keyboard input from 100 respondents using the function approach from my first post, and what I could salvage from your last post

#include<iostream>
using namespace std;
 
//function prototypes
void question1(int, int, int, int&);
void question2(int, int, int, int&);
void question3(int, int, int, int&);
 
int main()
{
  int grade, age, gender; //variables for user input
  int one, two, three;  //counters for results of questions
 
  //loop to get answers to three questions from 100 respondents
  for(i = 0; i < 100; i++)
  {
    cout<<"what is your highest grade?"<<endl;
    cout<<" enter 1 if grade is 10"<<endl;
    cout<<"enter 2 if grade is 12"<<endl;
    cout<<"enter 3 if tertiary qualification"<<endl;
    cin>>grade;
 
    cout << "how old are you?" << endl;
    cout << "enter 1 if below 20" << endl;
    cout << "enter 2 if between 20 and 30" << endl;
    cout << "enter 3 if above 32" << endl;
    cin>>age;
 
    cout << " what is your gender?" << endl;
    cout << "enter 1 if male"<<male << endl;
    cout << "enter 2 if female" << female << endl;
    cin >> gender;
 
    //pass information from each respondent to all three functions for analysis
    question1(grade, age, gender, one);
    question2(grade, age, gender, two);
    question3(grade, age, gender, three);
 }
 
  //display values of one, two, and three with appropriate verbal statements here.
 
  cin.gets();
  return 0;
}
 
//define functions here
void question1(int grade, int age, int gender, int& age)
{
   //analyze information sent in to see if information meets qualifications for question 1.
} …
nkhosinathie 0 Light Poster

this is what i came out with

#include<iostream>
using namespace std;

int main()
{
int num,age,gender,grade,grade10=0,grade12=0,tertiary=0;
int agebelow20=0;
int agebetween20and30=0;
int ageabove32=0;
int male=0;
int female=0;
int heterosexual=0;
for(i=0;i>=100;i++)
{
cout<<"what is your highest grade?"<<endl;
cout<<" enter 1 if grade is 10"<<endl;
cout<<"enter 2 if grade is 12"<<endl;
cout<<"enter 3 if tertiary qualification"<<endl;
cin>>grade;


if (grade==1)
{grade10=grade10+1;}
else
if(grade==2)
{grade12=grade12+1;}

else
if(grade==3)
{tertiary=tertiary+1;}

cout<<"how old are you?"<<endl;
cout<<"enter 1 if below 20"<<endl;
cout<<"enter 2 if between 20 and 30"<<endl;
cout<<"enter 3 if above 32"<<endl;
cin>>age;

if
(age==1)
{agebelow20=agebelow20+1;}

else

if(age==2)
{agebetween20and30=agebetween20and30+1;}

else
if(age==3)
{ageabove32=ageabove32+1;}

cout<<" what is your gender?"<<endl;
cout<<"enter 1 if male"<<male<<endl;
cout<<"enter 2 if female"<<female<<endl;
cin>>gender;
}

return 0;
}

i hope this will u help u to instruct me the next stepcos i'm already stucked

nkhosinathie 0 Light Poster

sir my problem is now i'm stucked so i don't know how to continue.please help

nkhosinathie 0 Light Poster

thank u sir this is what i did now.

#include<iostream>
using namespace std;
int main()
{
int num,age,gender,grade,grade10=0,grade12=0,tertiary=0;
int agebelow20=0;
int agebetween20and30=0;
int ageabove32=0;
int male=0;
int female=0;
int heterosexual=0;
for(i=1;i>=100;i++)
{
cout<<"what is your highest grade?"<<endl;
cout<<" enter 1 if grade is 10"<<endl;
cout<<"enter 2 if grade is 12"<<endl;
cout<<"enter 3 if tertiary qualification"<<endl;
cin>>grade;
 
 
if (grade==1)
{grade10=grade10+1;}
else
if(grade==2)
{grade12=grade12+1;}
 
else
if(grade==3)
{tertiary=tertiary+1;}
 
cout<<"how old are you?"<<endl;
cout<<"enter 1 if below 20"<<endl;
cout<<"enter 2 if between 20 and 30"<<endl;
cout<<"enter 3 if above 32"<<endl;
cin>>age;
 
if
(age==1)
{agebelow20=agebelow20+1;}
 
else
 
if(age==2)
{agebetween20and30=agebetween20and30+1;}
 
else
if(age==3)
{ageabove32=ageabove32+1;}
 
 
 
cout<<" what is your gender?"<<endl;
cout<<"enter 1 if male"<<male<<endl;
cout<<"enter 2 if female"<<female<<endl;
cin>>gender;
}
return 0;
}

now it is compiling but i want to know how to make it calculate the number of males between20-30 with the highest grade12,female between 20-30 with tertiary qualification and the number of people above 32,and then i have to add the total of the three.

nkhosinathie 0 Light Poster

sir which simple arrays are ur refferring to and we haven't done the classes yet but can u tell me about those classes that can help me please

nkhosinathie 0 Light Poster

i can assure u sir this program is giving me sleepless nights

nkhosinathie 0 Light Poster

thanks sir i will change that but my question is my output is the calculation of males between 20-30
females between 20-30
and people older than 32
so how can i increment them and initialised them

nkhosinathie 0 Light Poster

this is what i did.

#include<iostream>
using namespace std;
int main()
{
int maleage32;int femaleage32;int maleagebetween20and32;int femaleagebetween20and32;
int highestgrade;int tertiary;int gender;int malebetween20and30=1;
int i;int age;int age20;int age32;int agebetween20and32;
int male;int female;int heterosexual;int between20and30;
int highestgrade10;int highestgrade12;int olderthan30;

int total;int femalebetween20and30=2;int peopleolderthan30=3;
char m=male; char gendermale;
char f=female;char genderfemale;
char h=heterosexual;char genderheterosexual;
for (i<100;i++;)
highestgrade10=1;
highestgrade12=2;
tertiary=3;
m=male;
f=female;
h=heterosexual;
cout<<"what is your highest grade?"<<endl;
cin>>highestgrade;

age20=1;
maleagebetween20and32=2;femaleagebetween20and32;
maleage32=3;femaleage32=2;
 
cout<<"how old are you?"<<endl;
cin>>age;
gendermale =m;
genderfemale=f;
genderheterosexual=h;
cout<<" what is your gender?"<<endl;
cin>>gender;

total=malebetween20and30+femalebetween20and30+peopleolderthan30;
heterosexual=femalebetween20and30+malebetween20and30;
female=femalebetween20and30;
male=malebetween20and30;
if (gender=m,highestgrade=2)
cout<<"number of males between 20 and 30 and the highest grade12";
else if (gender=heterosexual,highestgrade=3)
cout<<"the number of people older than 30 with a tertiary qualification";

else if(gender=f,highestgrade=3)
cout<<"the number of females between 20 and 30 with a tertiary qualification";

else
cout<<"the total of males,female and people older than 30 is"<<total;
 
 
 
 
return 0;
 
 
 
 
 
}
nkhosinathie 0 Light Poster

my problem is this below information that is there whereas it is npt important in the output of the program whereas its part of the program. this information below.

how old are?
1.if below 20
2.if between 20-32
3.if above 32

what is your highest grade.
1.if grade 10
2.if grade 12
3.if teriary qualification.

what is your gender?
1.m if male
2.f if female
3. if heterosexual.

the output is

calcutlation of nale between 20-30
calculation of female between 20-30
calculation of people aboqve 32 where gender doesn't matter

and lastly displaying the total of the three information above.
my loop is starting at 100 because that is the total of the people who were doing this survey

nkhosinathie 0 Light Poster

tertiary refers to the higher grade than matric so it refers to any qualification more than matric,example a diploma,degree etc

nkhosinathie 0 Light Poster

so which loop control is a possibility to be used

nkhosinathie 0 Light Poster

hello everyone. i'm calculating certain 100 people that have completed a questionnaire and my program has to dertermine the number of males between20-30 and their highest grade which is grade 12,also the program has to determine the number of people above 32 and their highest grade which is tertiary as well as the program has to determine the number of females between 20-30 and their highest grade which is tertiary. this is what i did.

#include<iostream>
using namespace std;
int main()
{
int maleage32;int femaleage32;int maleagebetween20and32;int femaleagebetween20and32;
int highestgrade;int tertiary;int gender;int malebetween20and30=1;
int i;int age;int age20;int age32;int agebetween20and32;
int male;int female;int heterosexual;int between20and30;
int highestgrade10;int highestgrade12;int olderthan30;

int total;int femalebetween20and30=2;int peopleolderthan30=3;
char m=male; char gendermale;
char f=female;char genderfemale;
char h=heterosexual;char genderheterosexual;
for (i<100;i++;)
highestgrade10=1;
highestgrade12=2;
tertiary=3;
m=male;
f=female;
h=heterosexual;
cout<<"what is your highest grade?"<<endl;
cin>>highestgrade;

age20=1;
maleagebetween20and32=2;femaleagebetween20and32;
maleage32=3;femaleage32=2;
 
cout<<"how old are you?"<<endl;
cin>>age;
gendermale =m;
genderfemale=f;
genderheterosexual=h;
cout<<" what is your gender?"<<endl;
cin>>gender;

total=malebetween20and30+femalebetween20and30+peopleolderthan30;
heterosexual=femalebetween20and30+malebetween20and30;
female=femalebetween20and30;
male=malebetween20and30;
if (gender=m,highestgrade=2)
cout<<"number of males between 20 and 30 and the highest grade12";
else if (gender=heterosexual,highestgrade=3)
cout<<"the number of people older than 30 with a tertiary qualification";

else if(gender=f,highestgrade=3)
cout<<"the number of females between 20 and 30 with a tertiary qualification";

else
cout<<"the total of males,female and people older than 30 is"<<total;
 
 
 
 
return 0;

so my problem is this program doesn't show the neccesary results that i want pleaee help.i have tried but i need help

nkhosinathie 0 Light Poster

sir then how can i force the user to enter the righr information

nkhosinathie 0 Light Poster

the loop is starting from hundred because hundred people completed the following questionnaire.
what is your highest qualification
1.if grade 10
2.if grade 12
3.if any tertiary qualification
how old are you
1.if below 20
2.if between 20-32
3.if above 32
what is your gender.
1.m if male
2.f if female
3.h if hetero

nkhosinathie 0 Light Poster

I Want To Use A For Loop To Enter Three Answers From Three Questions But My Problem Is I Don't Have An Idea Coz I'm New To This C++ Language Please Help? THE LOOP STARTS TO COUNT FROM 100

nkhosinathie 0 Light Poster

so how must i go about doing that i mean the pseudocode of th program

nkhosinathie 0 Light Poster

my question is i want help to develop a pseudocode for this program before i can compile it

nkhosinathie 0 Light Poster

hello everyone.
i'm developing a program containing a for loop where the answer of each each respondent to each questrion is read in.

the program is saying:100 people conmpleted the following questionaire:
what is your highest qualification?
1.if grade 10
1.if grade 12
3. if any tertiary qualification

how old are u?
1.if below 20
2.between 20-32
3.if above 32

what is your gender
1.
m if male
2.f if female
3.h if hetero
the program has to determine
a)the number of males aged between 20-32 and highest qualification
b)the number of people older than30 with a tertiary qualification
c)the number of females aged between 20-30 with a tertiary qualification and display the three total.

i'm just asking for a pseudocode the rest i will do please help

nkhosinathie 0 Light Poster

i'm writing a pseudocode for a program that ask a user to enter a data and the program should forced the user to enter a required information.using a for loop.

the program is like this.

women between the following agea 20.20-30,32 above
men between the ages 20,20-30 and 32 above
heterosexuals 20,20-30,32 above.

which highest grade did you obtained? grade 10,matric,tertiary,

determine the number of males 20-30
women 20-30
hetero 20-30

nkhosinathie 0 Light Poster

hello everyone.

i'm developing a program from a department-store customerhas exceeded the credit limit on a charge account.for each of the following facts are available.account no,balance of the begining of the month,i total of all items charged by this customer,total of all credit applied to this customer.'m required to instal all the items using while loop.

so what i did is,

int enterInfo=0;
while(enterInfo<5) (x++);
do{
int account,startBalance,endBalance.allowed,credits,charges;

cout<<"enter account number";
cin>>account;

cout<<"enter credits applied to account";
cin>>credits;

cout<<"enter credit card charges";
cin>>charges;

cout<<"enter starting balance";
cin>>startbalance;

cout >>"credit limit?";
cin>>allowed;

so i don't know how to proceed and ene the program please someone help

nkhosinathie 0 Light Poster

Once again, I'm not sure if this is what you're looking for. Maybe someone else would be able to give you a hand here in the forums. Otherwise, drop me an IM via AIM.

hello i'm so happy to tell u that u have already helped me,i was looking for that program about a department-store customer program, but my question is what if i don't use that if statement.

nkhosinathie 0 Light Poster

thanks so much for your help i will try it and i will definitely get back to u'thanks

another thing i can ask if u don't mind, i'm also doing a bank account program but i will do it and come back to u,but what i want to know about it is the understanding of how i have to do.

nkhosinathie 0 Light Poster

>i'm prepared to listen and learn.i'm not here to copy any stqatements i'm here tyo learn
:icon_rolleyes:

>and also this programming has to be done using if statement only
That's exactly why I think you're meant to use recursion. The only other way is to write the code inline:

int main()
{
  // Print the square and cube of 0
  // Print the square and cube of 1
  // Print the square and cube of 2
  ...
  // Print the square and cube of 9
}

That doesn't use an if statement, and neither does your current solution. So my conclusion is that you need to approximate this:

int main()
{
  for ( int i = 0; i < 10; i++ ) {
    // Print the square and cube of i
  }
}

Which can be done with a recursive function using an if statement as the base case:

void f ( int i )
{
  if ( i < 10 ) {
    // Print the square and cube of i
    f ( i + 1 );
  }
}

int main()
{
  f ( 0 );
}

>you can just write
>using namspace std;
That's generally considered a bad practice though because it opens up names that you don't use and defeats the purpose of namespaces in avoiding naming collisions.

>but still whenever i compile this program it is leaving this numbers in
>between so i don't know how to deal with that.
The numbers in between …

nkhosinathie 0 Light Poster

instead of writing
using std::cout;
using std::cin;
using std::endl;

you can just write
using namspace std;

thanks i will do. but still whenever i compile this program it is leaving this numbers in between so i don't know how to deal with that.

nkhosinathie 0 Light Poster

thanks i will do. but still whenever i compile this program it is leaving this numbers in between so i don't know how to deal with that.

nkhosinathie 0 Light Poster

so how can i use the recursive loop because firstly i'm new to c++ programming and also this programming has to be done using if statement only.i'm prepared to listen and learn.i'm not here to copy any stqatements i'm here tyo learn

nkhosinathie 0 Light Poster

what was that about? don't you hate it when users come here asking questions without even having investigated on their own, try to figure out what's their problem, or even read any of the many books about there are?

i mean... i ran into you guys after like three weeks of investigation, which became useless, since i found anything helpful 4 my project...

besides... we're not whining... we're just telling people, warning people that we are not here to do their works... we're here to help them open their eyes...

u are definitely correct because some of us we are new to programming so help us inorder for us to help others

nkhosinathie 0 Light Poster

i'm developing a c++ program here and also i'm nwe to c++.
i have been given a program that has to print integers from 0-10 with their squares and cubes in a table form. but the problem is i'm only allowed to use if statement onyl to do this program.well this is how i did it.

#include<iostream>
using namespace std;
using std::cout;
using std::cin;
using std::endl;

int main()
{
int a;int b;int c;int d;int e;int f;int g;int h;int i;int j;int k;
int square;
int cube;

cout<<"enter any number"<<endl;
cin>>a;
square=a*a;
cube=a*a*a;

cout<<a<<"\t"<<square<<"\t"<<cube<<endl;

cin>>b;
square=b*b;
cube= b*b*b;

cout<<b<<"\t"<<square<<"\t "<<cube<<endl;

return 0;
}

i repeated the statement until i used all the variables above.
it appears like this

integer square cube
0 0 0
1
1 1 1
2
2 2 2

my problem is how to remove this numbers between because it has to appear like this

integer square cube
0 0 0
1 1 1
2 2 2