PDA

View Full Version : Quick Java Help!



ooo
07-14-2003, 05:09 PM
import java.io.*;

public class FunctionalCal{
public static void main (String[] args) throws IOException{
    BufferedReader option = new BufferedReader(
    (new InputStreamReader(System.in)));
   
int num1=0;
int num2=0;
int choice;
double result=0;

// ------------------------------------------------------------------------
// Beginning of the application. You will be asked several questions and
// you will have to submit a response.
// ------------------------------------------------------------------------
               
        choice = Calculator.number();
        if(choice!=6){
        System.out.println("Enter an integer:");
        num1 = Integer.parseInt(option.readLine());
        System.out.println("Enter another integer:");
        num2 = Integer.parseInt(option.readLine());
        }
       
            while(choice !=6){
            if (choice == 1){
            result = Calculator.add(num1,num2);}
            if (choice == 2){
            result = Calculator.subtract(num1,num2);}
            if (choice == 3){
            result = Calculator.multiply(num1,num2);}
            if (choice == 4){
            result = Calculator.divide(num1,num2);}
            if (choice == 5){
            result = Calculator.pow(num1,num2);}
           
            System.out.println(result);
            choice = Calculator.number();
            if (choice!=6){
            System.out.println("Enter an integer:");
            num1 = Integer.parseInt(option.readLine());
            System.out.println("Enter another integer:");
            num2 = Integer.parseInt(option.readLine());
            }
            }
         
            System.out.println("G O O D B Y E");}
       
       

}


import java.io.*;

public class Calculator{
public static int number() throws IOException{
    BufferedReader option = new BufferedReader(
    (new InputStreamReader(System.in)));
   
int number;

        System.out.println("\nMain Menu\n");
        System.out.println("1) Add");
        System.out.println("2) Subtract");
        System.out.println("3) Multiply");
        System.out.println("4) Divide");
        System.out.println("5) Raise to a power");
        System.out.println("6) Quit");
        number = Integer.parseInt(option.readLine());
       
        return(number);
}

public static int add(int a, int B) throws IOException{
    BufferedReader add = new BufferedReader(
    (new InputStreamReader(System.in)));
   
int result;

    result = a + b;
   
        return(result);
}

public static int subtract(int a, int B) throws IOException{
    BufferedReader subtract = new BufferedReader(
    (new InputStreamReader(System.in)));
   
int result;

    result = a - b;
   
        return(result);
}

public static int multiply(int a, int B) throws IOException{
    BufferedReader multiply = new BufferedReader(
    (new InputStreamReader(System.in)));
   
int result;

    result = a * b;
   
        return(result);
}

public static int divide(int a, int B) throws IOException{
    BufferedReader divide = new BufferedReader(
    (new InputStreamReader(System.in)));
   
int result;

    result = a/b;
   
        return(result);
}

public static int pow(int a, int B) throws IOException{
    BufferedReader pow= new BufferedReader(
    (new InputStreamReader(System.in)));
   
int result;

    result = Math.pow(a,B);
   
        return result;
}

}

TOP ONE IS MY MAIN ONE... the second is my class...

i keep getting this error!?!?

>>

java.lang.NoSuchMethodError: main
Exception in thread "main"

any clues?.. it worked before i was showing someone how to do this...

Wolfmight
07-14-2003, 08:24 PM
The Method of whatever your trying to do is not correct.. try reprogramming it to use a different way to do whatever u want it to do..
I've used java before.. there's many tweaks u can do.
What exactly are you trying to do?
Looks like some sort of "internet quiz".

bill oddie
12-26-2007, 08:24 PM
java is for cheese mechanics.