You are making an electronic quiz for some children in school. You are going to
ID: 3754813 • Letter: Y
Question
You are making an electronic quiz for some children in school. You are going to ask the following 5 questions and tell them their percent correct at the end Question 1: 5+7-? Question 2: 5-7-? Question 3: What animal goes "woof"? Question 4: What are the three primary colors? Question 5: What state do we live in? These questions should have the following answers: Answer 1: 12 Answer 2: -2 Answer 3: dog Answer 4: blue green red (in any order) Answer 5: minnesota Ask the questions in the exact order shown above. The answer will always be in lower case and exactly as shown above, except question 4 can have the colors in any order (so answering "red green blue" is correct, but not "green green green"). You can assume they will always give three colors for question 4. Example 1 (user input is underlined) Question 1: What is 5+7 200 Question 2: What is 5-7? Question 3: What animal goes "woof"? doggie Question 4: What are the three primary colors? Question 5: What state do we Iive in? Your percent correct: 40Explanation / Answer
#include<iostream>
using namespace std;
int main()
{
int ans,count=0,flag=0;
string StrAns,color1,color2,color3;
cout<<"Question 1: What is 5+7?"<<endl;
cin>>ans;
if(ans==12)
count++;
cout<<"Question 2: What is 5-7?"<<endl;
cin>>ans;
if(ans==-2)
count++;
cout<<"Question 3: What animal goes ""Woof""?"<<endl;
cin>>StrAns;
if(StrAns=="dog")
count++;
cout<<"Question 4: What are the primary colors?"<<endl;
cin>>color1;
cin>>color2;
cin>>color3;
if(color1=="red"||color1=="blue"||color1=="green")
{
if(color2=="red"||color2=="blue"||color2=="green")
{
if(color3=="red"||color3=="blue"||color3=="green")
count++;
}
}
cout<<"Question 4: What state do we live in?"<<endl;
cin>>StrAns;
if(StrAns=="minnesota")
count++;
cout<<"Your percent correct:"<<endl;
cout<<count/5*100;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.