Question:
C# visual studio debug problem?
2010-09-23 09:07:19 UTC
ok the code lies below, but firstly my problem is that when i debug i try to enter some numbers but i am only able to enter one number because after pressing enter it will not allow me to enter another one

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Maximum_and_Minimum_Number_Retriver
{
class Program
{
static void Main(string[] args)
{
double input;
double maximum;
double minimum;

Console.WriteLine("enter the numbers");
input = double.Parse(Console.ReadLine());

maximum = input;
minimum = input;

while (input != -999)


if (input > maximum)
{
input = maximum;
}

else if (input < minimum)
{
input = minimum;
}

input = double.Parse(Console.ReadLine());

Console.Read();
}
}
}
Four answers:
peteams
2010-09-23 09:23:42 UTC
You have a pair of braces missing, change to middle bit to include them thus:



while (input != -999)

{



if (input > maximum)

{

input = maximum;

}



else if (input < minimum)

{

input = minimum;

}



input = double.Parse(Console.ReadLine());

}
?
2010-09-23 09:24:30 UTC
Because your while(input != -999) block is missing starting and ending braces. Without those, only the if statement applies to the while.



Also, in the if statement for assigning new minimum or maximum values, you have the lines reversed. You're changing the input value instead of the limit values.



I recommend you switch to the OTBS style of using braces if at all possible so it becomes easier to see when you've left a brace off of a statement. (You can't easily and accidentally insert code between a loop/conditional statement and the opening brace that way.)
?
2016-10-05 11:57:21 UTC
that's form of of code making use of Dev C++. i've got confirmed it and it particularly works. //application to remodel temperature from Celsius degree products into //Fahrenheit = Celsius * (212 - 32)/one hundred +32 // #contain iostream making use of namespace std; int maximum severe() double celsius = 0; double fahrenheit = 0; fahrenheit = (9.0/5.0) * celsius + 32.0; //enter the temp in C cout << "enter the temperature in Celsius:" << endl; cin >> celsius; //calculate conversion factor for celsius //to F //use conversion part of convert C //into F values //output the outcomes (follwed by way of NewLine) cout << "Fahrenheit cost is:" << endl; cout << fahrenheit << endl; //wait til person is in a position formerly terminating application //to enable individual to look consequences equipment("PAUSE"); return 0; ---- utilising namsepace std; //namespace spelled incorrectly. Fahrenheit = (9.0/5.0) * celsius + 32.0;// that's a plenty less difficult formula than the single you used. The C++ ebook i've got has diverse questions concerning to Celsius-Fahrenheit conversion and that's the formula used. Int suitable( in nNumberofArgs, char* pszArgs[])//I have no suggestion what the stuff in the brackets is, although you do not surely want it. In element;// i've got self assurance that for the duration of will could be int
AJ
2010-09-23 09:13:04 UTC
Try using forms and not a console app.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...