A survey asks a person the percent of time at work they spend working, web-surfing, socializing, eating, and daydreaming. The person should enter the percents as 5 integers that should add to 100. Read 5 integers, and output OK if they sum to 100. Otherwise, output "Total should be 100. Your total: ___".
If the input is 20 30 10 10 30, the output is: OK
If the input is "80 10 10 10 5", the output is:
Total should be 100. Your total: 115
#include <iostream>
using namespace std;
int main() {
int work, web, social, eat, dream, total=0;
cout<<"The percent of time at work you spend : "<<endl;
cout<<"working: ";
cin>>work;
total = total + work;
cout<<"web-surfing: ";
cin>>web;
total = total + web;
cout<<"socializing: ";
cin>>social;
total = total + social;
cout<<"eating: ";
cin>>eat;
total = total + eat;
cout<<"daydreaming: ";
cin>>dream;
total = total + dream;
cout<<endl;
if(total==100)
cout<<"OK"<<endl;
else
cout<<"Total should be 100. Your total: "<<total<<" the percent of time at work you spend ";
cout<<endl;
return 0;
}
Comments
Leave a comment