Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


wabbz111

Member Since 30 Aug 2007
Offline Last Active Yesterday, 12:31 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.

Regards

#include<cstdlib>
#include<iostream>
#include<string>

#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";

        do
        {
        	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<<"<D>Mona\n\n";
        	
        	cout<<"Enter your vote : ";
        	cin>>choice;
        	
       	 
	   switch(choice)
	       {
            	case 'A':
            	case 'a':
            		pa++;
             	break;
            	//use new case for other presidential candidates
            	
            	
            	//for senators
                case 'D':
            	case 'd':
            		sa++;
            		break;
            	//use new case for other senatorial candidates
       	   }

            	cout<<"-----------------------\n";
            	cout<<"Enter <v>vote <r> result and <q> quit : \a";
            	cin>>choice2;
            	 
        }
	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";
            	cout<<endl;
	        }
	     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
	
        
        system("pause");
        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

PARTNERS