logo
down
shadow

Program crashes when no value is entered


Program crashes when no value is entered

By : David Jonker
Date : November 20 2020, 09:01 AM
hope this fix your issue Use This Main_Menu() method instead of yours. You will get smooth output.
code :
    private void Main_Menu()
        {
            Console.WriteLine("1). Welcome");
            Console.WriteLine("2). Help Facilities");
            Console.WriteLine("3). Exit");

            string userChoiceSTR = Console.ReadLine();

            if (!string.IsNullOrEmpty(userChoiceSTR))
            {
                userChoice = Convert.ToInt16(userChoiceSTR);
                try
            {
                Options();
            }
            catch
            {
                Console.WriteLine("Did not put any value. Please Select a menu: ");
                Main_Menu();
            }
            }
            else {
                Console.WriteLine("Did not put any value. Please Select a menu: ");
                Main_Menu();
            }
        }


Share : facebook icon twitter icon
When no data is entered the program crashes with data it is fine (android)

When no data is entered the program crashes with data it is fine (android)


By : Wilfried Mueller
Date : March 29 2020, 07:55 AM
should help you out The issue i'm having is that when I enter no data at all or if there is only data in one of the input boxes the program crashes but if there is any data in both boxes the program works fine so how do I stop it from sending data if nothing is entered. The error says it can parse a double of value "" , Chnage EditView for empty or null before making calculation :
code :
alculate.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
          if(distance.getText().toString().length() > 0){

            distanceTraveled = Double.parseDouble(distance.getText().toString());
        }
        else{
              distanceTraveled=0; // put default value here
          }
        if(fuel.getText().toString().length() > 0){  
               fuelUsed = Double.parseDouble(fuel.getText().toString());
          }
          else{
               fuelUsed=0;// put default value here

           }
            part1 = fuelUsed / 4.55;
            mpg = distanceTraveled / part1;
            total.setText(String.format("%.2f", mpg));
        }
    });
App crashes when I entered nothing on edittext

App crashes when I entered nothing on edittext


By : areloot
Date : March 29 2020, 07:55 AM
will help you It's an uncaught NumberFormatExpection on Integer.parseInt(txtbox1.getText().toString())
txtbox1 is empty when this method is called, so you're calling Integer.parseInt("") which throws a NumberFormatExpection.
Python Calculator Program Crashes When Invalid Equation Entered

Python Calculator Program Crashes When Invalid Equation Entered


By : ASHOK KUMAR
Date : March 29 2020, 07:55 AM
this one helps. When you enter invalid input, the actual exception raised is SyntaxError
code :
 >> -8*
Traceback (most recent call last):
  File "Test.py", line 19, in <module>
    exec(x)
  File "<string>", line 1
    x=-8*
        ^
SyntaxError: invalid syntax
 try:
     exec(x)
 except (ZeroDivisionError, SyntaxError):
     print ("WARNING: Invalid Equation")
 else:
     print(x)
App crashes if nothing entered

App crashes if nothing entered


By : Joe Kneifel
Date : March 29 2020, 07:55 AM
this one helps. Wild guess here. If (a, b, c) can be an empty string, then parseDouble probably throws NumberFormatException. Try moving the parsing code to the else block.
For loop function crashes when entered

For loop function crashes when entered


By : abdelilah
Date : March 29 2020, 07:55 AM
seems to work fine You should take double input with %lf specifier.
scanf("%lf",&marks[i]);
code :
int main(void)
{
    int students;

    students = noOfStud();
    char names[students][NAME_LEN];
    double marks[students];
    listStudents(students, names);
    options(students, marks);


    return 0;
}
Related Posts Related Posts :
  • How to get all ip address in LAN?
  • send value to controller using html.actionlink
  • Assembly "Microsoft.GeneratedCode" loaded
  • count the number of items in view in asp.net mvc
  • Shortcut Keys for Saving or Editing Record in C#
  • Very tricky/complex text formatting: How can I output a string[][] as a table?
  • Fill multiple textboxes after selecting a data from DropDownList in ASP.NET
  • How to launch an application after another is logged in in C#?
  • Unable to retrieve column values from one of the tables joined in a stored procedure?
  • Directories last file name display only
  • Why do I get a COMException when I try to initialize an Interop.Word.Application?
  • Finding subtotal for column in repeater control
  • dropdownlist item selected throw exception (stack empty)
  • How can I list IIS working processes programmatically?
  • How to access nested object from JSON with Json.NET in C#
  • OpenXml DataValidation set predefined List for columns
  • How to find recurring word groups in text with C#?
  • layout conrols to developp universal apps in windows 8.1 pro
  • Adding strings to a list via for loop xna
  • Using Vertex Arrays with OpenTK
  • Optimizing List<string>
  • C# Local variables
  • How can I merge the results of a group by Linq-to-XML query?
  • How to add Report in ASP.NET Project
  • C# How to display all instances of a loop in a label?
  • C# subscribe a function to System.Action that is subscribed to another System.Action: why does order matter?
  • Is there any negative effect to setting SqlCommand's CommandTimeout to a high value?
  • C# - TreeView Context Menu Out of Place when using keyboard
  • How to read stored procedure output and return it as list
  • How do you maintain changes made by VisualState triggers after setting another VisualState?
  • Should I be unit testing my bootstrapper and if so how?
  • using .SingleOrDefault() inside .Where() will raise the following exception:- System.NotSupportedException was unhandled
  • C# How would I fill a Form1 Parameter in the same seperate class
  • Access gridview row's data from LinkButton inside that row
  • Translating excel function to c# Math.pow not resulting in same values
  • Arranging Ten Inputted Numbers into Ascending and Descending order
  • AsEnumerable and Query Syntax
  • How can I defensively code against randomly referencing "Table 0" and null values?
  • Changing xaml code position based on screen size
  • Castle Windsor resolve ienumerable and name
  • Drawing multiple sprites with a for loop xna 4.0
  • For loop to Populate Textblocks
  • Visual Studio 2015: Create an Empty Project
  • What are .NET classes to replace the old MSXML2.ServerXMLHTTP?
  • Handle leak in .Net threads
  • Excel add-in ribbon click events bubbling
  • validation rule needed for only numbers to be entered
  • Parsing complex XML, no descendent elements exists when selecting a named element
  • Web Api - IEnumerable with complex type as param is null
  • Email address input validation
  • .Net AND operator Regular Expression using strings in a document
  • Windows phone 8.1 POST x-www-form-urlencoded not working
  • Is there any way to make my C# XMLManager work?
  • ASP.NET 5 Console Application (package) - How to create DBContext from connection string?
  • How to use form's function in other class C#
  • WPF Zebra EPL2 Printing issue
  • C# use reflection to capture exception throw
  • Convert strings in DataRow to double
  • Xml-Serialization is not working
  • HTML Agility Pack can't find classes with trailing spaces
  • shadow
    Privacy Policy - Terms - Contact Us © animezone.co