PLEASE USE C THANK YOU Write a program that does the followi
PLEASE USE C++:
THANK YOU!!
Write a program that does the following: Ask the user to input a floating point number, f First convert f to an integer number, n, Please output a message based upon the value of n Please use both if-then statement and switch-case statement to complete this task.Solution
#include <iostream>
using namespace std;
int main()
{
float f;
cout << \"Enter floating point number: \";
cin >> f;
int n = (int)f;
if( n%7 == 0 || n%7 == 6){
cout<<\"This is a weekend\"<<endl;
}
else {
cout<<\"This is a workday\"<<endl;
}
switch(n%7){
case 0:
case 6: cout<<\"This is a weekend\"<<endl;break;
case 1:
case 2:
case 3:
case 4:
case 5:cout<<\"This is a workday\"<<endl; break;
}
return 0;
}
Output:
sh-4.2$ g++ -o main *.cpp
sh-4.2$ main
Enter floating point number: 66.7
This is a workday
This is a workday
sh-4.2$ main
Enter floating point number: 55.5
This is a weekend
This is a weekend

