Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Eric Witowski
Courses Plus Student 92 PointsHelp modify a simple java code program, OVERLOADED HELP
I need help writing a simple program that will use overloaded method, requirements are you a business or residence, name and phone number? Then enter your name then enter your phone number
That's it seems so easy, I just would like some ideas PLEASE PLEASE.
import java.util.*;
class myCust {
void rect(int a,int b) {
int result = a*b; System.out.println(result);
}
void rect(double a,double b) {
double result = a*b; System.out.println(result);
} }
class rectarea { public static void main(String[] args)
{
myCust zo = new myCust();
Scanner input= new Scanner(System.in);
System.out.println("Please enter values:");
//I need to change this to accept 1 for business 2 for residence and then have name of person then name then
//phone number accepted by input?
double a = input.nextDouble();
double b = input.nextDouble();
zo.rect(a,b);
//or I can use just a very basic overloaded program, CONFUSED with ... in the syntax
public class genericId {
...
public void genId(String s) {
...
}
public void genId(int i) {
...
}
public void genId(double f) {
...
}
public void genId(int i, double f) {
...
}
}
1 Answer
Eric Witowski
Courses Plus Student 92 PointsI came to this website to work hard and give 1000% effort, I work at this 10 hours each day, and I am learning quickly, please help.