View Code of Problem 9

      #include <iostream>
      #include<string.h>
      using namespace std;
     /* run this program using the console pauser or add your own getch, system("pause") or input loop */
             
             
      int main(int argc, char** argv) {
     	int n;
      	int j=0;
      	int temp=0;
      	while(cin>>n){    	
       	char str[105];
       	char str1[100];
        int sum=0;
       	int flag=0;
       	for(int i=0;i<n;i++){
       		
      		cin>>str>>str1;
           	if(strcmp(str,"Pleasant")==0){ 	
          			sum=sum+5;
           			flag++;
            	}else if(strcmp(str,"Pretty")==0){
            		sum=sum+8;
            		flag++;
            	}else if(strcmp(str,"Athletic")==0){
            		sum=sum+10;
            		temp=1;
            		flag++;
            	}else if(strcmp(str,"Lazy")==0){
            		sum=sum+15;
            		flag=flag+1;
            	}else if(strcmp(str,"Slow")==0){
            		sum=sum+20;
            		flag=flag+1;
            	}
            	}
            	
            	if(flag>=10&&temp==1){
            		sum=sum+50;
            	}
            	cout<<"Case #"<<++j<<": "<<sum<<endl;
            	}
            		return 0;
            }

Double click to view unformatted code.


Back to problem 9