With Microsoft Visual Audio using C++ solve this problem Problem Statement Write
ID: 3665088 • Letter: W
Question
With Microsoft Visual Audio using C++ solve this problem
Problem Statement Write a program that First, asks the user whether increasing /decreasing should be "strict" or "lenient". Second, reads three integer numbers and prints "all the same" if they are all the same, "all different" if they are all different, and "neither the same nor different" otherwise. Third, if it is in lenient mode from the first step, as long as each value is larger than or equal to its predecessor except for all the same, your program printsand leniently increasing" following "neither the same nor different" from step two; when each value is larger than its predecessor, vour program prints "and strictly increasing" following "all different" from step two. If it is in strict mode from the first step, then you only need to consider the strictly increasing case, which means when each value is larger than its predecessor, vour program prints "and strictly increasing" following "all different" from step two. Note similar rules apply to decreasing order as well The following are some examples of running vour program: Enter s for strict ordering, L for lenient (s or L): A You chose the wrona mode, auittina the program... Running your program: Enter S for strictrdering, L for lenient (S or L) : S Please enter three integer numbers: 77 7 In strict mode... all the same Running your program: Enter s for strict ordering, L for lenient (S or L): s Please enter three integer numbers: 3 5 5 In strict mode... neither same nor differentExplanation / Answer
#include<iostream>
using namespace std;
int main()
{
cout << "Enter three numbers: ";
float n1, n2, n3;
cin >> n1 >> n2 >> n3;
cout << "Should increasing/decreasing be "strict" or "lenient"?: ";
string order;
cin >> order;
if(order == "strict")
{
if (n1 < n2 && n2 < n3 )
{
cout << "Increasing order. ";
}
else if (n1 > n2 && n2 > n3)
{
cout << "Decreasing order. ";
}
else
{
cout << "Neither. ";
}
}
if(order == "lenient")
{
if (n1 < n2 && (n2 < n3 || n2 == n3))
{
cout << "Increasing order. ";
}
else if (n1 > n2 && (n2 > n3 || n2 == n3))
{
cout << "Decreasing order. ";
}
else if (n1 == n2 && n2 == n3)
{
cout << "Both increasing and decreasing. ";
}
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.