Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions

Question

What are the main objectives of Inventory ?

Answered: 1 week ago

Question

Explain the various inventory management techniques in detail.

Answered: 1 week ago

Question

=+ For what reasons can and do unions go on strike?

Answered: 1 week ago

Question

=+ Is secondary industrial action common and/or legal?

Answered: 1 week ago

Question

=+What sanctions are available to employers

Answered: 1 week ago