Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

java - saving operators in arrays, error -


to give idea of want elaborate code following:

  1. enter 2 numbers: 10 7
  2. choose operator: e.g. (+, - , * , /)
  3. what's 10 * 7?
  4. correct!

    int[] arr = new int[5];   system.out.println("enter 2 numbers: "); arr[1] = sc.nextint(); arr[2] = sc.nextint();   system.out.println("choose operator: "); arr[3] = sc.nextint();   int operator = arr[1]+arr[3]+arr[2];   system.out.print("what's "+operator); int svar = sc.nextint();   if (svar == operator)     system.out.println("correct!"); else     system.out.println("wrong - right answer "+operator);     

now i'm having problem running aspects within code. works fine compile each time program asks "choose operator" compiler responses following error:

  • exception in thread "main"
    • java.util.inputmismatchexception at
    • java.util.scanner.throwfor(unknown
    • source) at
    • java.util.scanner.next(unknown
    • source) at
    • java.util.scanner.nextint(unknown
    • source) at
    • java.util.scanner.nextint(unknown
    • source)
    • at test1.main(test1.java:13)

i wonder how i'm going deal one. goal "save" desired operator, , put arr[1] , arr[2] (shown in int operator) "sort of" create whole mathematical operation. but error occurs when choose 1 particular operator.

i appreciate one. thank you!

firstly, trying use ints , strings interchangeably, not possible in strongly-typed language such java.

secondly, kind of calculator application should using stack. easiest implementation, have 1 stack numbers , 1 stack operators.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -