Answer to Question #332632 in C++ for Jessica Mayra

Question #332632

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
1
Expert's answer
2022-04-23T03:21:51-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS