473,395 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

why wont my program work?

Expand|Select|Wrap|Line Numbers
  1.  
  2. import javax.swing.JOptionPane;
  3.  
  4. import java.util.*;
  5. public class Assignment1
  6.  
  7. {
  8. // do nothing constructor
  9. public Assignment1()
  10. {}
  11. public static void main(String[]args)
  12. {
  13. Assignment1 assign = new Assignment1();
  14. assign.Runit();
  15. }
  16. private void Runit()
  17.     {
  18.  
  19.           //Gather the information from the user
  20.        Scanner input1 = new Scanner(System.in);
  21.        String gender = JOptionPane.showInputDialog("Gender: ");
  22.        Scanner input2 = new Scanner(System.in);
  23.        int age;
  24.        JOptionPane.showInputDialog("enter age: ");
  25.        age = input2.nextInt();
  26.  
  27.        JOptionPane.showInputDialog(age);
  28.  
  29.         if (age <= 17 )
  30.             System.out.println( "Person is a boy");
  31.         else  
  32.             System.out.println ( "Person is a Man");
  33.     }
  34.  
  35.  
  36. }
  37.  
  38.  
  39.  
Jun 14 '09 #1
1 1693
Nepomuk
3,112 Expert 2GB
Well first of all, because you're mixing command line input (Scanners for System.in) and input via Swing objects (InputDialogs). And secondly because you're not doing anything with the age you read in line 24. Have a good look at the lines 20 to 27 and think about what exactly they do.

Greetings,
Nepomuk
Jun 14 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Catherine | last post by:
I am having a problem viewing asp pages on iis version 5.1 xp pro. HTML pages are viewable on http://localhost but .asp pages are not. I have created a test program called timetest.asp with the...
7
by: Christine | last post by:
My code has a split function that should split the text file of numbers. I've run this in previous programs as it is here and it worked, but now it wont work for some reason and returns...
3
by: me | last post by:
Is there any particular reason why a requiredfieldvalidator cant validate a listbox? I have bound the two together but the validator always returns false on isvalid and so does the Page, no matter...
5
by: Mr Newbie | last post by:
Debug.Assert( False, "Why wont I display ??") I am trying to use this in my code but it wont display. The app is running on my local machine and the above code under a button click event. What...
2
by: ff2 | last post by:
Ok i'm using Borland CBX and Windows XP. My program is to convert farenheit to celsius. I got the code off the CD that came with "Sams Teach Yourself C++ in 24 Hours" so i doubt the code is wrong. I...
0
by: slughead | last post by:
people! im new here, please be nice... im having problem with the setup package in my recent project! need help please... i have created setup package to distribute the my software,...
4
by: carson | last post by:
I have written two windows services: - service A does some crunching of local data files and uploads them to a central processing computer via http. - service B monitors a manifest file on a...
3
Frinavale
by: Frinavale | last post by:
Hi there, I am currently behind a firewall that wont let me send emails. As a result my smtpClient.send(emailMessage) wont work on my IIS but this method does work through the VisualStudio...
2
by: jcollins1991 | last post by:
im trying to make a program thats supposed to check whether 2 strings are anagrams of each other (anagram = same letters in both strings, but in different orders... "cool as wet art" , and "cs at...
1
by: WestyCHC | last post by:
Morning all from a newbie. I have recently written an automation program (my first ever program) for testing and now I am trying to read XML data and assign the values to variables (rather than...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.