• Creating a Name Display Program in Java
    6 replies, posted
[code]/** * @(#)Review6.java * * Review6 application * * @author * @version 1.00 2010/11/15 */ import javax.swing.JOptionPane; import java.io.*; public class Review6 { public static void main(String[] args) throws IOException { //declaration of variables String snumber int numbers, Counter = 0; // TODO, add your application code snumber = JOptionPane.showInputDialog(null, "Type in a number",null,JOptionPane.INFORMATION_MESSAGE); numbers = Integer.parseInt(snumber); while (!done) { Counter = numbers try {if text = numbers; else done = true; JOptionPane.showMessageDialog(null, "John Smith is a terrible programmer",null,JOptionPane.INFORMATION_MESSAGE) } } } } [/code] I am absolutely terrible at programming. I am trying to make a program that prompts you to enter a number. Then, message boxes will display your name corresponding to the number you put in. I don't have a clue as to what I'm doing
Missing ; after first variable declaration Inconsistent formatting 'done' not declared Missing ; after assignment try-block without catch You probably want if(test == numbers.ToString()), not if test = numbers (which is missing parenthesis and is an assignment, not a comparison Also, text not declared Missing ; after functioncall to showMessgeDialog Loop makes no sense Conclusion: Less programming, more learning. If you're using a book or internet tutorial, you might wanna try a different one.
If you need good tutorials then this guy has pretty good ones. [url]http://www.youtube.com/watch?v=Hl-zzrqQoSE[/url]
You can't have a try without a catch kiddo. YOU JUST FUCKING CAN'T!!
I'm in a CS 144 class right now and we are nearing the end of it and we haven't even messed with panes yet. I suggest starting off simpler if you are just learning: [code]import java.util.Scanner; public class NameDisplay { public static void main(String[]args) { Scanner in = new Scanner(System.in); int num; System.out.print("Enter an integer: "); num = in.nextInt(); if (num == 1) { System.out.println("30CALIB3R"); } else { System.out.println("No name found"); } } }[/code]I think this is what you're trying to achieve.
[QUOTE=Werem00se;26097536]You can't have a try without a catch kiddo. YOU JUST FUCKING CAN'T!![/QUOTE] And no pokemon catching
[QUOTE=pikzen;26101004]And no pokemon catching[/QUOTE] Gotta Catch 'Em All!
Sorry, you need to Log In to post a reply to this thread.