Error(s) found: '1'

  • Unable to perform the query 'UPDATE cpp_code SET clickthru=clickthru+1 WHERE fid=47'. Table 'cpp_code' is read only.

  • C++ MADE EASY
    Code About Us Tutorial




       
     

    Home > myCode > Vote analysis program

    November 28, 2009 7:52 am

       

    Vote analysis program


    Posted on: 2005-03-08 01:31:26
    Number of times viewed: 51

     
     
    /* vote analysis program
       03/08/05 */
    
    #include <iostream.h>
    #include <lvpstring.h>
    
    int main()
    {
    	cout<<"--vote analysis program--"<<endl<<endl;
    
    	String Candidate1,Candidate2;
        cout<<"enter name of first candidate:";
    	getline(cin,Candidate1);
    	cout<<"enter name of second candidate:";
    	getline(cin,Candidate2);
    
    	long Votes1,Votes2;
    	cout<<"enter votes for "<<Candidate1<<":";
    	cin>>Votes1;
    	cout<<"enter votes for" <<Candidate2<<":";
    	cin>>Votes2;
    	cout<<endl;
    
    	long VotesTotal=Votes1+Votes2;
    	double Percent1=100*double(Votes1)/VotesTotal;
        double Percent2=100*double(Votes2)/VotesTotal;
    
    	const ColWidth=10;
    	cout.setf(ios::fixed);
    	cout.precision(2);
    
    	cout.setf(ios::left);
    	cout.width(ColWidth);cout<<"Candidate";
    	cout.setf(ios::right);
    	cout.width(ColWidth);cout<<"Votes";
    	cout.width(ColWidth);cout<<"Percent"<<endl;
    	
    	cout.setf(ios::left);
    	cout.width(ColWidth);cout<<"Candidate1";
    	cout.setf(ios::right);
    	cout.width(ColWidth);cout<<"Votes1";
    	cout.width(ColWidth);cout<<Percent1<<endl;
    
    	cout.setf(ios::left);
    	cout.width(ColWidth);cout<<"Candidate2";
    	cout.setf(ios::right);
    	cout.width(ColWidth);cout<<"Votes2";
    	cout.width(ColWidth);cout<<Percent2<<endl;
    	
    	cout.width(ColWidth);cout<<"TOTAL: "<<endl;
    	cout.width(ColWidth);cout<<VotesTotal<<endl;
    
    	if(Votes1==Votes2)
    		cout<<"its was a Tie!"<<endl;
    	
    	return(0);
    } 
    	
    	
    

    Please Rate this Code:



     «12039» THINKQUEST TEAM C0111571 © 2001. All Rights Reserved.