My java calculator is returning the error "one can not be resolved to a variable"? -


i trying make java calculator works multiplication, division, subtraction , addition. starting division part , incomplete, getting error says "one can not resolved variable". @ spot want make if type in "one" start division class. code main class:

import java.util.scanner;

class apples {     public static void main(string args[]) {          system.out.println("this calculator can divide, multiply, subtract , add. divide type in one, multiply type in two, subtract type in 3 , add type in four");         scanner input = new scanner(system.in);          int div, mult, sub, add;          if (input = one) {             division divisionobject = new division();         }          div = input.nextint();          mult = input.nextint();          sub = input.nextint();          add = input.nextint();          if(div > mult && div > sub && div >add){          }      } } 

code division class(i have not touched other classes yet): import java.util.scanner;

public class division {     public static void divide() {         int div1, div2, divanswer;         system.out.println("enter number divide: ");         div1 = input.nextint();     } } 

p.s keep in mind have been coding in java half week complete noob.

you should use string variable store choice entered user "one".

scanner input = new scanner(system.in); string choice = input.nextline(); 

also, change if condition :

if(choice.equalsignorecase("one")) 

{ division divisionobject = new division(); }

this check choice entered user.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -