Question
c++ cplusplus please make this code as simple as you can we only need to know the current and desired temperature to either cool the
c++ cplusplus please make this code as simple as you can
we only need to know the current and desired temperature to either cool the room, heat the room, or do neither
1. the command string cant be the EMPTY string ""
2. no spaces anywhere in the command string
3. must start with t or T
4. after user must type the current temperature in integers
5.after user must type c or C or h or H to either cool or heat the room
6. after user must type the desired temperature in integers
7. after user MAY type + or - followed by integers... if they want
8. user could repeat 7 as many times as they want if they want
----------------------------------------------------------------------------------------------------------------
********DIRECTIONS!!!!!!!!!!!!!!!
implement the following five functions, using the exact function names, parameter types, and return types shown in this specification.
1.bool isWellFormedThermostatString(string commands)
This function returns true if its string parameter is a well-formed thermostat command string, and false otherwise.
2.int temperature(string commands)
If the string parameter is a well-formed thermostat string, the function should return the current temperature found in the command string. Return -1 if the parameter is not well-formed.
3.int setting(string commands)
If the string parameter is a well-formed thermostat string, the function should return the user-desired setting value. Return -1 if the parameter is not well-formed. Return 0 if there is no setting value found.
4.bool isHeating(string commands)
If the string parameter is a well-formed thermostat string, the function should determine if the system is currently heating, returning true if it is heating and false otherwise. Return false if the parameter is not well-formed.
5.bool isCooling(string commands)
If the string parameter is a well-formed thermostat string, the function should determine if the system is currently cooling, returning true if it is cooling and false otherwise. Return false if the parameter is not well-formed.
------------------------------------------------------------------------------------------------------------------------
IF YOU NEED MORE HELP!
All of the following are examples of valid thermostat command strings:
T70 (a setting value is optional)
t70 (UPPERCASE and lowercase letters are valid)
t70c65 (current temperature=70 desired temperature=65 so system is currently cooling)
t70c71 (current temperature=70 desired temperature=71 so system is not currently cooling)
t70h75 (current temperature=70 desired temperature=75 so system is currently heating)
t70h65 (current temperature=70 desired temperature=65 so system is not currently heating)
t70c65+1+1 (current temperature=70 desired temperature=67 so system is currently cooling)
t70c70 (current temperature=70 desired temperature=70 so system is not currently cooling)
t70h70 (current temperature=70 desired temperature=70 so system is not currently heating)
t70h75-1-1 (current temperature=70 desired temperature=73 so system is currently heating)
All of the following are examples of invalid thermostat command strings:
(empty string is invalid)
t 70 c 68 (no spaces are supported in a command string)
t70c68zzzz (no other characters allowed)
t+70 (no leading plus with a temperature value allowed)
t-70 (no leading minus with a temperature value allowed)
t70c+68 (no leading plus with a setting value allowed)
t70c-69 (no leading minus with a setting value allowed)
t70c69+0 (increment value cannot be zero)
t70c69-0 (increment value cannot be zero)
c69t70 (temperature must be listed first)
t70+1c69 (increments must follow the setting value)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started