Enters an invalid temperature

Assignment Help Business Management
Reference no: EM132255339

An application named DailyTemps that continuously prompts a user for a series of daily high temperatures until the user enters a sentinel value of 999. Valid temperatures range from -20 through 130 Fahrenheit. When the user enters a valid temperature, add it to a total; when the user enters an invalid temperature, display the error message:

 Valid temperatures range from -20 to 130. Please reenter temperature. 

Before the program ends, display the number of temperatures entered and the average temperature.

This is my code below. It's not giving me what I need. I need average and number of Array. What am i doing wrong?

using System;

using static System.Console;

class DailyTemps

{

  static void Main()

  {

      int temp = 0;

           int total = 0;

 

          int [] tempNum = new int [temp];

           while (temp != 999)

           {

               WriteLine("Please enter a number valid temperature range from -20 to 130");

        temp = Convert.ToInt32(ReadLine());

               if ((temp >= -20) && (temp <= 130))

               {

               total = total + temp; 

               }

               else if (temp != 999)

               {

                   WriteLine("Valid temperature range is from -20 to 130. Please reenter temperature. ");

               }

                for (int i = 0; i < tempNum.Length; ++i)

                        {

                         total = total/tempNum.Length;

       }

           }

           WriteLine("The total temperature is {0}, {1}", tempNum.Length, total);

           ReadLine();

  }

}

Reference no: EM132255339

Questions Cloud

Define the classical school and positivism theories : Define the Classical School and Positivism Theories. Explain each of their positions on the role of punishment and the deterrence of crime.
Research current news for a common attack : Research current news for a common attack. for the example you have provided, describe the attack
High concentration of both short and long-haul services : Why is competition weak at airports that have a high concentration of both short and long-haul services?
Attacks for the example you have provided : Select a common attack, describe the attack and how organizations attempt to prevent the attack from happening
Enters an invalid temperature : When the user enters a valid temperature, add it to a total; when the user enters an invalid temperature, display the error message:
Controversies of air freight pricing for modern day airlines : Discuss the controversies of air freight pricing for modern day airlines?
Domestic violence laws that require law enforcement : Most states, have domestic violence laws that require law enforcement officers to arrest suspects for domestic related misdemeanor assaults not committed
Layout changes at wear technologies provided waste reduction : The layout changes at wear Technologies provided waste reduction from. Water striders are operators who stay at particular process work stations.
Lead to the reporting of lying statistics : Compile a list of behaviors or practices that can lead to the reporting of “lying statistics.”

Reviews

Write a Review

Business Management Questions & Answers

  How can employers benefit from alternative work arrangements

BA/420: How can employees benefit from alternative work arrangements? How can employers benefit from alternative work arrangements?

  Different billing procedures for medicare

Do you believe it is more or less efficient to use different billing procedures for Medicare, Medicaid, or private payers?

  Why does an entrepreneur need to write a business plan

Why does an entrepreneur need to write a business plan? What should a business plan mission statement include, and how long should it be?

  Impact on earnings per share for your company

Of these two types of capital which will have the most impact on earnings per share for your company?

  Discusses real problems in hierarchal organizations

In his 1990 work, "In Praise of Hierarchy," Elliott Jaques discusses real problems in hierarchal organizations. His critique identifies the following issues?

  United states expenditures on health

What are the three reasons why United States expenditures on health differ from other OECD countries? What factors explain why the United States has a health disadvantage compared to other wealthy nations?

  How did motivation affect thomas level of managerial hubris

Journal of Management History, 20(2), 164-178. How did corporate culture, leadership, power, and motivation affect Thomas' level of managerial hubris?

  Describe the concept of the consumption function

What are the main determinants of the level of National Income? Describe the concept of the consumption function, verbally, graphically and mathematically. How is equilibrium of the National Income attained?

  What does it mean to have a fair division of something

According to the book, what does it mean to have a fair division of something?

  Describe the impact of those challenges on todays leaders

What are the challenges facing leaders in today's environment? Consider both internal and external challenges within an organization. Describe the impact of those challenges on today's leaders. Explain how leaders need to respond to them.

  Create a vision with employee involvement

Addresses create a vision with employee involvement - explain the process you would engage to create a vision for the organization and how you would get employees involved in that vision.

  Industries and their major business segments

What are the core components are within the characteristics, scope, and economic significance of the Aerospace

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd