My assignment is to write an overloaded version of iquote(), a method that displays the type of its argument and its argument enclosed in double quotation marks. I am asked to write three versions: one for int argument, one for a double argument and one for a String argument. I am not required to supply an application part.
This is what i have so far, it will compile however a get an error message: Could not find or load main class assign61
Could someone please help me with this code…
public class assign61 {
public void iquote(String s){
return sQuote;
System.out.println( "sQuote\" );"
}
public void iquote(int n){
return iQuote;
System.out.println( "sQuote\" );"
}
public void iquote(double d){
return iQuote;
System.out.println( "sQuote\" );"
}
}
Your code can’t be compiling properly because there are errors in it. Therefore, if it wont compile, it can’t be run.
There are a few changes that you need to make…
Basically this is what needed to change…
System.out.println()lines by the+symbol.returnstatements in your methods, but they aren’t what you want to use.returnis for returning a value to the code that called the method – they aren’t for outputting a value to the command prompt.returnstatements, they also would have prevented your code from compiling because you had them written before yourSystem.out.println()statements instead of after them.returncan’t have anything written after it in the code. Also, to usereturnstatements, you would need to change your methods to bepublic int iQuote(int n)instead of using thevoidstatement, so it knows what type of data you’ll be returning from the methodassign61which has some test code in it to show that your other methods work correctly. I have also added themainmethod so that you can run your code.I hope this helps you to understand a little more. Try making some of the changes suggested above, then compile your code. Once it compiles correctly, you will be able to run it. Then you can come back to us with any further problems.