| | |
Scanner & Message Box
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Mar 2007
Posts: 68
Reputation:
Solved Threads: 1
I am have no idea wat is wrong with my code. The system is supposed to get 3 inputs from users and display a message box to show the number in ascending order. If i were to get input from input box and display it in message box it will work perfectly but when i tried to modify it where the input were taken from scanner and display it in message box. The program just stopped when i entered the 3rd integer. Any1 can give me some idea wat is wrong? Here is my code:
Java Syntax (Toggle Plain Text)
import java.util.Scanner; import javax.swing.JOptionPane; class lab3q2 { public static void main(String[] args) { Scanner abc = new Scanner(System.in); System.out.print("Enter 3 integers\nfirst integer: "); int int1 = abc.nextInt(); System.out.print("\nSecond integer: "); int int2 = abc.nextInt(); System.out.print("\nThird integer: "); int int3 = abc.nextInt(); int min, med, max; if(int1 > int2) { med = int1; min = int2; } else { med = int2; min = int1; } if(int3 > med) { max = int3; } else { max = med; med = int3; } JOptionPane.showMessageDialog(null,"The sorted number are "+min+" "+med+" "+max, "SimpleSortingOutput",JOptionPane.INFORMATION_MESSAGE);
Try adding a System.out.println(); before the JOptionPane to see where the program stops
Check out my New Bike at my Public Profile at the "About Me" tab
![]() |
Similar Threads
- 100% CPU usage & hardware interrupts.......2 (Viruses, Spyware and other Nasties)
- Spyfalcon & Malwarewipe, and I can't get ride of it! (Viruses, Spyware and other Nasties)
- Removal of "Home Search Assistant", "Search Extender", & "Shopping Wizard" (Viruses, Spyware and other Nasties)
- hotoffers & others on pc-please help (Viruses, Spyware and other Nasties)
Other Threads in the Java Forum
- Previous Thread: Threading query
- Next Thread: Binary to decimal
| Thread Tools | Search this Thread |
2dgraphics account android api apple applet application array arrays automation banking binary binarytree bluetooth chat chatprogramusingobjects class classes client code component data database derby design draw eclipse encryption error event exception fractal game givemetehcodez graphics gui html ide if_statement image inheritance input integer interface j2me java javadesktopapplications javaprojects jlabel jni jpanel jtextfield julia linux list loop map method methods midlethttpconnection mobile monitoring netbeans newbie nullpointerexception open-source oracle print printing problem program programming project property recursion reference ria scanner screen search server set size sms sort sourcelabs splash sql static stop string swing testautomation threads time tree ui unicode validation windows






