Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 30 Aug 2007
Offline Last Active Aug 01 2015 12:18 AM

Posts I've Made

In Topic: C++ do while error

19 March 2015 - 12:09 AM

Thanks for the replies I have done the correction but i want it to display the PMenu until i press r || R which

will then print the results

This program was working without classes but i am now trying to use classes and that is why iam a bit stuck.

The original program without classes is below. You can see what iam trying to do with the current class arrangement.



#define PI = 3.142
using namespace std;

int main()
    system("COLOR CE"); 
	char choice,choice2;
	//for presidents
    int pa=0,pb=0,pc=0,pTotal=0;
	//string PName="Wamalwa";
	//for senators
	int sa=0,sb=0,sc=0,sTotal=0;
	//string SName="Mona";

        	cout<<"\t Presidential Elections\n\n";
        	cout<<"Candidates \n\n";
        	//add more presidential candidates here
        	cout<<"<A> Wamalwa \n";
        	cout<<"<B> Robert\n";
        	cout<<"\t senators Elections\n\n";
            cout<<"Candidates \n\n";
            //add more senatorial candidates here
        	cout<<"Enter your vote : ";
            	case 'A':
            	case 'a':
            	//use new case for other presidential candidates
            	//for senators
                case 'D':
            	case 'd':
            	//use new case for other senatorial candidates

            	cout<<"Enter <v>vote <r> result and <q> quit : \a";
	while(choice2=='V' || choice2=='v');
    	if (choice2=='R' || choice2=='r')
                //presidential results
            	cout<<"\t Presidential Elections\n\n";
            	cout<<"Candidates:"<<"\t results:"<<"\n\n";
            	cout<<"<A>Wamalwa : "<<pa<<"\a\n";
            	//_______senatorial results
                cout<<"\t Senatorial Elections\n\n";
            	cout<<"Candidates \n\n";
            	cout<<"<D>Mona: "<<sa<<"\n";
            	pTotal=pa; //for other presidential canndidates add the variables
            	sTotal=sa;//for other senatorial canndidates add the variables
            	//count total votes
            	cout<<"Total Presidential Votes cast : "<<pTotal<<"\n";
            	cout<<"Total Senatorial Votes cast : "<<sTotal<<"\n";
	     if (pa > pb && pa > pc)
        		cout<< " The presidential winner is : Wamalwa " << endl;
    //hint use else if for more candiates
  //for senators
         if (sa > sb && sa > sc)
    		    cout<< " The senatorial winner is : Mona " << endl;
	//hint use else if for more candiates
        return 0;

In Topic: c++ friend classes

05 March 2015 - 12:03 AM

@SeanMiddleditch I will definetly try this one out. Meanwhile let me do more practice i will also be posting another program(using classes vehicle and bicycle) soon that hopefully can use friend classes beter.

In Topic: c++ friend classes

04 March 2015 - 04:07 AM

Thanks @Paradigm Shifter i will now try it with the Steer() method private. I added porsche.Steer(); in PorscheSteer(); then in the main method called Cayenne.Steer(car); and it worked.


@SeanMiddleditch  I hear you great advice but if you dont mind how about an example to clear up any lingering concerns.Regards

In Topic: Polygon count

20 November 2012 - 10:08 AM

Alright i will try it and let you know thanks.

In Topic: Polygon count

20 November 2012 - 09:34 AM

I am using lines for trunk and branches, with leaves represented by an octahedron.
Since l-system generate the tree recusivelt i get mant branches and leaves.
I would like to know if there is a way to approximate how many are on the screen
.please look at the picture attached to see what i mean