Quantcast
Channel: Active questions tagged crash - Stack Overflow
Viewing all articles
Browse latest Browse all 7195

Program that will output three integers in descending ordrer

$
0
0

This program is meant to prompt a user to enter three integers, store the integers in three separate variables, and output the three integers in descending order (highest to lowest values).

import java.util.Scanner;public class ProgramToo{public static void main(String [] args){  Scanner kbd = new Scanner(System.in);  System.out.println("Enter the first number:");  int num1 = kbd.nextInt();  System.out.println("Enter the second number:");  int num2 = kbd.nextInt();  System.out.println("Enter the three number:");  int num3 = kbd.nextInt();  int result = largeSmall(num1, num2, num3);  System.out.println(result);  }  public static int largeSmall(int one, int two, int three)  {  if(one > two && two > three)  {     System.out.println(one +""+ two +""+ three);  }  else if(two > one && one > three)  {     System.out.println(two +""+ one +""+ three);  }  else if(three > two && two > one)  {     System.out.println(three +""+ two +""+ one);  }  else  {     System.out.println(one +""+ three +""+ two);  }  return largeSmall(one, two, three);  }  }       

When I run this program, it outputs the integers a million times and crashes. Why?


Viewing all articles
Browse latest Browse all 7195

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>