• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

how to fix error in java calculator in udicity course?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was trying to run this code but it's not working.

You should create a calculator with its basic functions.

Create a calculator class which has sum, subtract, division, and multiply methods, all of them take two int parameters and return the resulted int.

Example: When the sum method is called as sum(5,6), it should return 11 which is the sum of 5 and 6

How can I fix it ?




An error occurred: Test 1 method sum in class MyCalculator cannot be applied to given types; required: no arguments found: int,int reason: actual and formal argument lists differ in length method divid in class MyCalculator cannot be applied to given types; required: no arguments found: int,int reason: actual and formal argument lists differ in length method subtract in class MyCalculator cannot be applied to given types; required: no arguments found: int,int reason: actual and formal argument lists differ in length method multiply in class MyCalculator cannot be applied to given types; required: no arguments found: int,int reason: actual and formal argument lists differ in length

Correct any cells that are not running correctly, and use Restart and Run All from the Kernel menu to be sure all cells are running correctly. Then click Test Code again to check your results.
 
Saloon Keeper
Posts: 9556
79
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do all the methods return a float when requirement specify an int?
Why does multiply() say "average" in the comment?
Why doesn't multiply() take any arguments?
 
Marshal
Posts: 76403
364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
W4elcome to the Ranch

Please find out how the code button works. Since you are new, I have used ti on your code, and doesn't it look better. Unfortunately your formatting could be better; use empty lines between methods rather than inside methods, and indent line 4 please. We are not simply being fussy; we see many people who get confused because they haven't formatted their code correctly.

Please re‑read the requirements because they tell you what the methods should be called, and what parameters they will have. Note that such methods are what the mathematicians call pure functions, so the methods might well be made static and called like this:- System.out.println(MyCalculator.multiply(123, 456));
As for floats: I suggest you forget they even exist, unless somebody else tells you to use a float.
 
A magnificient life is loaded with tough challenges. En garde tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic