How to use while true loop for this qustion?
Show older comments
The Fahrenheit temperature is converted to Celsius temperature by the following formula , write a script file to accept temperature in Fahrenheit and calculate its Celsius equivalent for 5 times using DO WHILE loop.
While writing the Program please consider the Following:
- The program must ask the user to input the temperature in Fahrenheit.
- The program must display the temperature in Celsius.
7 Comments
stozaki
on 19 Sep 2020
Hello mahmoud,
Do you want to calculate the average of 5 times of "C" ?
stozaki
mahmoud Tarek
on 19 Sep 2020
Walter Roberson
on 19 Sep 2020
This is not what is needed. The complete assignment was posted before but got deleted.
The requirement posted before was to use a "do while" loop. Each time through the loop, the program needs to prompt for a value and do temperature conversion and display the value. The loop is to be executed five times.
The assignment does not involve mean(): it involves using a while loop with exit condition at the end to loop a fixed number of times.
This is of course very easy so I have been explaining the structure to use instead of explicitly showing the counter logic, hoping to get the user to think about how to turn the general situation into the particular one. The user has not posted any attempts yet and the volunteers are likely getting the impression that the user is hoping that someone will provide a complete solution.
mahmoud Tarek
on 19 Sep 2020
Edited: mahmoud Tarek
on 19 Sep 2020
Walter Roberson
on 19 Sep 2020
I do not at the moment recall any limits on the input temperatures. I would tend to expect that if temperatures as low as 0K are permitted then you would want to allow temperatures higher than 100C.
mahmoud Tarek
on 23 Sep 2020
Edited: mahmoud Tarek
on 24 Sep 2020
Walter Roberson
on 24 Sep 2020
It's okay.
Accepted Answer
More Answers (1)
Hello
Here is an example of calculation
% Define the value of F used in the calculation as a "vector".
F = [70 80 75 84 92];
% Calculate the average value of F using the mean function.
AveC = mean(5/9*(F - 32))
AveC =
26.7778
documentation for mean function
stozaki
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!