d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Basic Calculator Problem
Add Reply New Topic New Poll
Member
Posts: 12,565
Joined: Dec 29 2007
Gold: Locked
Mar 23 2013 12:32am
Code
import java.util.Scanner;

class apples{
public static void main(String args[]) {
   Scanner chris= new Scanner(System.in);
   double fnum, snum, answer;
   System.out.println("enter first number");
   fnum = chris.nextDouble();
   System.out.println("what is the second number");
   snum = chris.nextDouble();
   answer = fnum + snum;
   System.out.println(answer);
   }
}


the error i am getting is "Exception in thread "main" java.lang.Error: Unresolved compilation problem:

at bucky.apples.main(apples.java:4)"

can someone help me please

This post was edited by clanwkya on Mar 23 2013 12:45am
Member
Posts: 24,396
Joined: Oct 21 2007
Gold: 0.38
Mar 23 2013 10:46am
Why exactly is your main within a class? :huh:

Also, "args" is the parameter name which is an array of Strings, you have args and [ ] in the wrong order; it should be "... main( String [ ] args )"


This post was edited by DeadlySanity on Mar 23 2013 10:48am
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Mar 23 2013 11:20am
@op how about you try compiling it first and give us the compile error?

@DealySanity main is a method that needs to be in a class. im pretty sure order doesnt matter for the brackets, but not 100%

This post was edited by carteblanche on Mar 23 2013 11:23am
Member
Posts: 12,565
Joined: Dec 29 2007
Gold: Locked
Mar 23 2013 02:48pm
Quote (carteblanche @ 23 Mar 2013 12:20)
@op how about you try compiling it first and give us the compile error?

@DealySanity main is a method that needs to be in a class. im pretty sure order doesnt matter for the brackets, but not 100%


nvm i had a semi colon in the main
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll