PLEASE FIX AND MODIFY THIS JAVA PROGRAM SO WHEN I UPLOAD IT TO HYPERGRADE IT PASSES ALL TEST CASSES PLEASE. RIGHT NOW IT SAYS 0 OUT 5 PASSED. THE PROGRAM IS NOT WORKING IN HYPERGRADE FIX IT SO IT WILL WORK IN HYPERGRADE. THANK YOU.
JAVA PROGRAM
PLEASE FIX AND MODIFY THIS JAVA PROGRAM SO WHEN I UPLOAD IT TO HYPERGRADE IT PASSES ALL TEST CASSES PLEASE. RIGHT NOW IT SAYS 0 OUT 5 PASSED. THE PROGRAM IS NOT WORKING IN HYPERGRADE FIX IT SO IT WILL WORK IN HYPERGRADE. THANK YOU.
import java.util.Scanner;
public class Main {
public static double calculateRetail(double wholesale, double percentage) {
if (percentage < -100) {
throw new IllegalArgumentException("Markup cannot be less than -100%.");
}
return wholesale + wholesale * (percentage / 100);
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double wholesale;
double percentage;
do {
System.out.println("Please enter the wholesale cost: ");
wholesale = sc.nextDouble();
} while (wholesale < 0);
do {
System.out.println("Please enter the markup percentage: ");
percentage = sc.nextDouble();
} while (percentage < -100);
double retailPrice = calculateRetail(wholesale, percentage);
System.out.printf("The retail price is: %.2f\n", retailPrice);
}
}
Test Case 1
10ENTER
Please enter the markup percentage or -1 exit:\n
-1ENTER
Test Case 2
100ENTER
Please enter the markup percentage or -1 exit:\n
100ENTER
The retail price is: 200.00\n
Please enter the wholesale cost or -1 exit:\n
-1ENTER
![Test Case 3
Please enter the wholesale cost or -1 exit: \n
10 ENTER
Please enter the markup percentage or -1 exit: \n
50 ENTER
The retail price is: 15.00 \n
Please enter the wholesale cost or -1 exit: \n
10 ENTER
Please enter the markup percentage or -1 exit: \n
100 ENTER
The retail price is: 20.00 \n
Please enter the wholesale cost or -1 exit: \n
10 ENTER
Please enter the markup percentage or −1 exit: \n
-100 ENTER
The retail price is: 0.00 \n
Please enter the wholesale cost or -1 exit: \n
-1 ENTER](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F0866e38f-1852-4268-b445-f17fa0369bf3%2F13a000fc-9897-42e9-88a5-f4f0ba0e0cd6%2Fth11cud_processed.png&w=3840&q=75)
![Test Case 4
Please enter the wholesale cost or -1 exit: \n
-200 ENTER
Wholesale cost cannot be a negative value.\n
Please enter the wholesale cost again or -1 exit: \n
10 ENTER
Please enter the markup percentage or -1 exit: \n
-200 ENTER
Markup cannot be less than -100%. \n
Please enter the markup again or -1 exit: \n
50 ENTER
The retail price is: 15.00 \n
Please enter the wholesale cost or -1 exit: \n
-1 ENTER
Test Case 5
Please enter the wholesale cost or -1 exit: \n
-1 ENTER](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F0866e38f-1852-4268-b445-f17fa0369bf3%2F13a000fc-9897-42e9-88a5-f4f0ba0e0cd6%2Fkdvenla_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 4 steps with 6 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Operations Research : Applications and Algorithms](https://www.bartleby.com/isbn_cover_images/9780534380588/9780534380588_smallCoverImage.gif)
![Programming with Microsoft Visual Basic 2017](https://www.bartleby.com/isbn_cover_images/9781337102124/9781337102124_smallCoverImage.gif)
![Operations Research : Applications and Algorithms](https://www.bartleby.com/isbn_cover_images/9780534380588/9780534380588_smallCoverImage.gif)
![Programming with Microsoft Visual Basic 2017](https://www.bartleby.com/isbn_cover_images/9781337102124/9781337102124_smallCoverImage.gif)
![Systems Analysis and Design (Shelly Cashman Serie…](https://www.bartleby.com/isbn_cover_images/9781305494602/9781305494602_smallCoverImage.gif)