View Code of Problem 9

#include<string>
#include<iostream>
using namespace std;
int main(){	
	string str;int k=0;int n;
	while(scanf("%d",&n)!=EOF)
	{
		getchar();
		int sum=0,flag=0;
		for(int i=0;i<n;i++)
		{
			getline(cin,str);
			if(str=="Pleasant goat")
			{
				sum+=5;
			}
			else if(str=="Pretty goat")
			{
				sum+=8;
			}
			else if(str=="Athletic goat")
			{
				flag=1;
				sum+=10;
			}
			else if(str=="Lazy goat")
			{
				sum+=15;
			}
			else if(str=="Slow goat")
			{
				sum+=20;
			}
		}
		if(n>=10&&flag==1)
		printf("Case #%d: %d\n",++k,sum+50); 
		else
		printf("Case #%d: %d\n",++k,sum);
	}
} 

Double click to view unformatted code.


Back to problem 9