Need a project done?

C++ Programming Developer

Search This Blog

C++ basic percentage program

/*
WRITE A PROGRAM THAT WILL ASK SOMEONE HOW THEY SPEND THEIR DAY. aT LEAST 5 QUESTIONS:
HOW MANY HOUR DO YOU SPEND SLEEPING,
HOW MANY HOURS FO SPEND EATING,
DRINKING,
WALKING,
WORKING,.
CALCULATE PERCENTAGES
THE OUTPUT SHOULD LOOK SOMETHING LIKE THIS.
SLEEPING EATING DRINKING WALKING WORKING
40.00% 40.00% 7.00% 4.00% 9.00%
*/



#include <iostream>
using namespace std;

int main()
{
cout << "You spend time (in hours) in 1 day: " <<endl;
cout << "In Playing: "; int play; cin >> play;
cout << "In Sleeping: "; int sleep; cin >> sleep;
cout << "In Eating: "; int eat; cin >> eat;
cout << "In Working: "; int work; cin >> work;

cout << "In percentage: " << endl;
cout << "Playing: " << play/24.0 * 100 << "%" << endl;
cout << "Sleeping: " << sleep/24.0 * 100 << "%" << endl;
cout << "Eating: " << eat/24.0 * 100 << "%" << endl;
cout << "Working: " << work/24.0 * 100 << "%" << endl;

return 0;
}

No comments:

Post a Comment

"Don't let anyone ever make you feel like you don't deserve what you want."