Wisconsin State Fair is one of the largest midsummer celebrations in the Midwest Allis, showcasing the agriculture skills and prowess of the state. The Event organizers hired few part-time employees to work at the fair and the agreed salary paid to them are as given below:
Weekdays --- 80 / hour
Weekends --- 50 / hour
Justin is a part-time employee working at the fair. Number of hours Justin has worked in the weekdays is 10 more than the number of hours he had worked during weekends. If the total salary paid to him in this month is known, write a program to estimate the number of hours he had worked during weekdays and the number of hours he had worked during weekends.
Input Format:
First line of the input is a double value that corresponds to the total salary paid to Justin.
Output Format:
First line of the output should display the number of hours Justin has worked during the weekdays.
Second line of the output should display the number of hours Justin has worked during the weekends.
Refer sample input and output for formatting specifications.
[All text in bold corresponds to input and rest corresponds to output.]
Sample Input and Output:
Enter the total salary paid
2750
Number of weekday hours is 25
Number of weekend hours is 15
Answers
Answer:#include<iostream>
using namespace std;
int main()
{
int a;
cin>>a;
for(int i=10; i<=a;i++)
{
int x=80*i+50*(i-10);
if(a-x>=0 & & a-x<130)
{
cout<<"number of weekdays hours"<<i<<"\n"<<"number of weekdays hours"<<(i-10);
}
}
return 0;
}
Explanation:weekdays and weekends should be differ by 10 so I multiply 80 with i and multiply 50(i-10)
If condition statement checks a-x value >=0(i.e; we got the value weekdays an weekends value is satisfying) and a-x<130 (because 80+50 =130 then it will increments one to weekday hour and one to weekend hours)
If condition satisfied it will print weekdays hours, weekend hours.
Explanation:
#include<iostream>
using namespace std;
int main()
{
int a;
cin>>a;
for(int i=10; i<=a;i++)
{
int x=80*i+50*(i-10);
if(a-x>=0 & & a-x<130)
{
cout<<"number of weekdays hours"<<i<<"\n"<<"number of weekdays hours"<<(i-10);
}
}
return 0;
}
weekdays and weekends should be differing by 10
So we can multiply 80 with i and multiply 50(i-10)
If the condition statement checks a-x value >=0
we got the value weekdays and weekends value is satisfying
and
a=x < 130 because 80+50 =130 then it will increment one to weekday hour and one to weekend hours
If the condition is satisfied it will print weekdays hours, weekend hours.