Answer:
Step-by-step explanation:
The following code is written in Java and creates the overloaded methods as requested. It has been tested and is working without bugs. The test cases are shown in the first red square within the main method and the output results are shown in the bottom red square...
class Auction {
public static void main(String[] args) {
bid(10);
bid(10.00);
bid("10 dollars");
bid("$10");
bid("150 bills");
}
public static void bid(int bid) {
if(bid >= 10) {
System.out.println("Bid Accepted");
} else {
System.out.println("Bid not high enough");
}
}
public static void bid(double bid) {
if(bid >= 10) {
System.out.println("Bid Accepted");
} else {
System.out.println("Bid not high enough");
}
}
public static void bid(String bid) {
if (bid.charAt(0) == '$') {
if (Integer.parseInt(bid.substring(1, bid.length())) > 0) {
System.out.println("Bid Accepted");
return;
} else {
System.out.println("Bid not in correct Format");
return;
}
}
int dollarStartingPoint = 0;
for (int x = 0; x < bid.length(); x++) {
if (bid.charAt(x) == 'd') {
if (bid.substring(x, x + 7).equals("dollars")) {
dollarStartingPoint = x;
} else {
break;
}
}
}
if (dollarStartingPoint > 1) {
if (Integer.parseInt(bid.substring(0, dollarStartingPoint-1)) > 0) {
System.out.println("Bid Accepted");
return;
} else {
System.out.println("Bid not in correct format");
return;
}
} else {
System.out.println("Bid not in correct format");
return;
}
}
}