Question

Write a program that will ask for a desired temperature and it shifts the conditions in the Fig. shown below. - The program w

States Heater AC High - 3 - Med - 2 6 Low - 1 Off - 01 4ó số 50 to go 90 Temp (F) Desired Temp = 72.5Please enter the room temperature: 90 Please enter the desired temperature: 65 printf cooling = 3 printf heating = 0 Please e

Writing a program in C using CodeBlocks but I cannot seem to get this right. I keep getting weird outputs for my high, med, low.

Any help would be greatly appreciated. Code is provided in link.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

/*

program to decide the level of cooling or heating required

input - room and desired temprature as float

output - heating or cooling level

*/

#include <stdio.h>

int main() {
   float room = 0, desired = 0, diff = 0;
   int coolingLevel = 0, heatingLevel = 0;
   printf("\nPlease enter the room Temprature");
   scanf("%f",&room);
  
   printf("\nPlease enter the desired Temprature");
   scanf("%f",&desired);
  
   diff = (room>desired?room-desired:desired-room);
  
   if(diff > 2.5)
   {
     
   if (room > 75.1 && room < 85) //Else if ladder to decide the level of cooling or heating.... Change condition if required.
   coolingLevel = 1;
  
   else if (room > 85.1 && room < 95)
   coolingLevel = 2;
  
   else if (room > 95.1)
   coolingLevel = 3;

   else if (room > 60 && room < 69.99)
   heatingLevel = 1;

   else if (room > 50 && room < 59.99)
   heatingLevel = 2;

   else if (room <49.99)
   heatingLevel = 3;

  
   }
   printf("\nprintf cooling = %d",coolingLevel);
   printf("\nprintf heating = %d",heatingLevel);
   return 0;
}

Add a comment
Know the answer?
Add Answer to:
Writing a program in C using CodeBlocks but I cannot seem to get this right. I...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The following is a program from Starting out with C++ by Toni Gaddis. I am getting the following error messages pertain...

    The following is a program from Starting out with C++ by Toni Gaddis. I am getting the following error messages pertaining to the lines: cin>>month[i].lowTemp; and months[i].avgTemp = (months[i].highTemp + month[i].lowTemp)/2; The error messages read as follows: error C2039: 'lowTemp': is not a member of 'std::basic_string<_Elem,_Traits,_Ax>' and it continues. The second error message is identical. The program is as follows: Ch. 11, Assignment #3. pg. 646. Program #4. //Weather Statistics. //Write a program that uses a structure to store the...

  • Question2 uses structured design implemented in C. Array of records (structs) with file I/O is needed....

    Question2 uses structured design implemented in C. Array of records (structs) with file I/O is needed. The program takes two inputs at a time. The name of a person, and, the coin value as an integer in the range 5 to 95. Input coin values should always be divisible by 5 (integer division). Names are one word strings. An example input is: Jane 30 This input line indicates that 30 cents change is to be given to Jane. Output change...

  • Hello! I'm posting this program that is partially completed if someone can help me out, I...

    Hello! I'm posting this program that is partially completed if someone can help me out, I will give you a good rating! Thanks, // You are given a partially completed program that creates a list of employees, like employees' record. // Each record has this information: employee's name, supervisors's name, department of the employee, room number. // The struct 'employeeRecord' holds information of one employee. Department is enum type. // An array of structs called 'list' is made to hold...

  • Coding in C++ Write a program using structures to store the following weather information: - Month...

    Coding in C++ Write a program using structures to store the following weather information: - Month name - Day of month (Monday, Tuesday, etc) - High Temperature - Low Temperature - Rainfall for the day Use an the input.txt file to load the data into weather structures. Once the data for all the days is entered, the program should calculate and display the: - Total rainfall for the data - Average daily temperatures. (note: you'll need to calculate the days...

  • I need your help solving this thermodynamics problem please: Question Completion Status: QUESTION 1 20 points...

    I need your help solving this thermodynamics problem please: Question Completion Status: QUESTION 1 20 points Save Ans The heat-pump system shown is designed to provide water-heating and space-cooling. The system includes a heat exchanger to subcool the R134a refrigerant at the outlet of the water heater while heating the refrigerant at the outlet of the evaporator. Given the following data, determine the enthalpy at each station, 1 through 6, using the R134a property tables (click here). Type your answers...

  • I need help to write a nice introduction for experiment 6 please ( no hands write ) typing Thank you HEAT TREATMENT OF STEELS EXPERIMENT 6 EXPERIMENT 6 HEAT TREATMENT OF STEELS THEORY The Ef...

    I need help to write a nice introduction for experiment 6 please ( no hands write ) typing Thank you HEAT TREATMENT OF STEELS EXPERIMENT 6 EXPERIMENT 6 HEAT TREATMENT OF STEELS THEORY The Effect of Cooling Rate One of the most convenient methods for controlling the properties of a given steel, i.e., a steel whose composition is already fixed, consists of austenizing the steel and ten cooling to room temperature at some predetermined rate. A variation of cooling rates...

  • summarizr the followung info and write them in your own words and break them into different...

    summarizr the followung info and write them in your own words and break them into different key points.   6.5 Metering Chamber: 6.5.1 The minimum size of the metering box is governed by the metering area required to obtain a representative test area for the specimen (see 7.2) and for maintenance of reasonable test accuracy. For example, for specimens incorporating air spaces or stud spaces, the metering area shall span an integral number of spaces (see 5.5). The depth of...

  • summatize the following info and break them into differeng key points. write them in yojr own...

    summatize the following info and break them into differeng key points. write them in yojr own words   apartus 6.1 Introduction—The design of a successful hot box appa- ratus is influenced by many factors. Before beginning the design of an apparatus meeting this standard, the designer shall review the discussion on the limitations and accuracy, Section 13, discussions of the energy flows in a hot box, Annex A2, the metering box wall loss flow, Annex A3, and flanking loss, Annex...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT