How to use while true loop for this qustion?
显示 更早的评论
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 个评论
stozaki
2020-9-19
Hello mahmoud,
Do you want to calculate the average of 5 times of "C" ?
stozaki
mahmoud Tarek
2020-9-19
Walter Roberson
2020-9-19
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
2020-9-19
编辑:mahmoud Tarek
2020-9-19
Walter Roberson
2020-9-19
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
2020-9-23
编辑:mahmoud Tarek
2020-9-24
Walter Roberson
2020-9-24
It's okay.
采纳的回答
更多回答(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
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!