Michaeljs1990
February 26th, 2010, 09:56 PM
I'm pretty new to programming and am enjoying it quite a lot. The projects they give us to do for class are way to easy so i decided to make a program for fun. however when i try and compile this program to test it out i get...
package javaapplication1;
/********************************************
*Michael Schuett
*2/25/10
*Java
*This is my first semi-big java program
***********************************************/
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
String input= h;
Scanner stdIn = new Scanner(System.in);
System.out.println("Hello, Welcome to MMath Beta 0.1");
System.out.println("What would you like to do? (for help enter h): ");
input = stdIn.next();
if (h);
{
System.out.print("type in add to add or subtract numbers." + '\n');
System.out.print("type in mult to multiply or divide." + '\n');
System.out.print("only 2 currently available in Beta 0.1" + '\n');
}
}
}
and i get the error code
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - cannot find symbol
symbol: variable h
location: class javaapplication1.Main
at javaapplication1.Main.main(Main.java:15)
Java Result: 1
BUILD SUCCESSFUL (total time: 2 seconds)
can anyone explain how i can get the input 'h' from the user to bring up the if statement? Sorry if this is a stupid question.
package javaapplication1;
/********************************************
*Michael Schuett
*2/25/10
*Java
*This is my first semi-big java program
***********************************************/
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
String input= h;
Scanner stdIn = new Scanner(System.in);
System.out.println("Hello, Welcome to MMath Beta 0.1");
System.out.println("What would you like to do? (for help enter h): ");
input = stdIn.next();
if (h);
{
System.out.print("type in add to add or subtract numbers." + '\n');
System.out.print("type in mult to multiply or divide." + '\n');
System.out.print("only 2 currently available in Beta 0.1" + '\n');
}
}
}
and i get the error code
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - cannot find symbol
symbol: variable h
location: class javaapplication1.Main
at javaapplication1.Main.main(Main.java:15)
Java Result: 1
BUILD SUCCESSFUL (total time: 2 seconds)
can anyone explain how i can get the input 'h' from the user to bring up the if statement? Sorry if this is a stupid question.