473,289 Members | 1,884 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,289 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 1691
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.