Write a program that asks the user to enter an item’s wholesale cost and its markup percentage. It should then display the item’s retail price. For example: • If an item’s wholesale cost is 5.00 and its markup percentage is 100 percent, then the item’s retail price is 10.00. • If an item’s wholesale cost is 5.00 and its markup percentage is 50 percent, then the item’s retail price is 7.50. The program should have a method named calculateRetail that receives the wholesale cost and the markup percentage as arguments, and returns the retail price of the item. Class name: RetailPriceCalculator   Here is a working code: please modify this code so it works in Hypergrade when I submit it so it passes all the test casses in Hypergrade.Because right now when I upload it to Hypergrade it says 0 out of 5 casses pased.  It has to pass all the test casses in Hypergrade  Please fix this code. I do not need thanks for playing or goodbye in  the program.    import java.util.Scanner; public class RetailPriceCalculator {     public static void main(String[] args) {         Scanner keyboard = new Scanner(System.in);         while (true) {             double wholesaleCost = getWholesaleCost(keyboard);             if (wholesaleCost == -1) {                 break;             }             double markupPercentage = getMarkupPercentage(keyboard);             if (markupPercentage == -1) {                 break;             }             double retailPrice = calculateRetail(wholesaleCost, markupPercentage);             System.out.printf("The retail price is: %.2f%n", retailPrice);         }         keyboard.close();     }     public static double getWholesaleCost(Scanner keyboard) {         System.out.println("Please enter the wholesale cost or -1 to exit:");         double cost = keyboard.nextDouble();         if (cost == -1) {             return -1;         } else if (cost < 0) {             System.out.println("Wholesale cost cannot be a negative value.");             return getWholesaleCost(keyboard);         }         return cost;     }     public static double getMarkupPercentage(Scanner keyboard) {         System.out.println("Please enter the markup percentage or -1 to exit:");         double percentage = keyboard.nextDouble();         if (percentage == -1) {             return -1;         } else if (percentage < -100) {             System.out.println("Markup cannot be less than -100%.");             return getMarkupPercentage(keyboard);         }         return percentage;     }     public static double calculateRetail(double wholesaleCost, double markupPercentage) {         return wholesaleCost * (1 + markupPercentage / 100);     } }         Test Case 4     Please enter the wholesale cost or -1 exit:\n -200ENTER Wholesale cost cannot be a negative value.\n Please enter the wholesale cost again or -1 exit:\n 10ENTER Please enter the markup percentage or -1 exit:\n -200ENTER Markup cannot be less than -100%.\n Please enter the markup again or -1 exit:\n 50ENTER The retail price is: 15.00\n Please enter the wholesale cost or -1 exit:\n -1ENTER   Test Case 5     Please enter the wholesale cost or -1 exit:\n -1ENTER

Information Technology Project Management
9th Edition
ISBN:9781337101356
Author:Kathy Schwalbe
Publisher:Kathy Schwalbe
Chapter7: Project Cost Management
Section: Chapter Questions
Problem 9QQ
icon
Related questions
Question
Chapter 5. PC #2. Retail Price Calculator (page 312)
Write a program that asks the user to enter an item’s wholesale cost and its markup percentage. It should then display the item’s retail price. For example:
• If an item’s wholesale cost is 5.00 and its markup percentage is 100 percent, then the item’s retail price is 10.00.
• If an item’s wholesale cost is 5.00 and its markup percentage is 50 percent, then the item’s retail price is 7.50.
The program should have a method named calculateRetail that receives the wholesale cost and the markup percentage as arguments, and returns the retail price of the item.
Class name: RetailPriceCalculator
 
Here is a working code: please modify this code so it works in Hypergrade when I submit it so it passes all the test casses in Hypergrade.Because right now when I upload it to Hypergrade it says 0 out of 5 casses pased.  It has to pass all the test casses in Hypergrade  Please fix this code. I do not need thanks for playing or goodbye in  the program. 
 

import java.util.Scanner;

public class RetailPriceCalculator {
    public static void main(String[] args) {
        Scanner keyboard = new Scanner(System.in);

        while (true) {
            double wholesaleCost = getWholesaleCost(keyboard);
            if (wholesaleCost == -1) {
                break;
            }

            double markupPercentage = getMarkupPercentage(keyboard);
            if (markupPercentage == -1) {
                break;
            }

            double retailPrice = calculateRetail(wholesaleCost, markupPercentage);
            System.out.printf("The retail price is: %.2f%n", retailPrice);
        }

        keyboard.close();
    }

    public static double getWholesaleCost(Scanner keyboard) {
        System.out.println("Please enter the wholesale cost or -1 to exit:");
        double cost = keyboard.nextDouble();
        if (cost == -1) {
            return -1;
        } else if (cost < 0) {
            System.out.println("Wholesale cost cannot be a negative value.");
            return getWholesaleCost(keyboard);
        }
        return cost;
    }

    public static double getMarkupPercentage(Scanner keyboard) {
        System.out.println("Please enter the markup percentage or -1 to exit:");
        double percentage = keyboard.nextDouble();
        if (percentage == -1) {
            return -1;
        } else if (percentage < -100) {
            System.out.println("Markup cannot be less than -100%.");
            return getMarkupPercentage(keyboard);
        }
        return percentage;
    }

    public static double calculateRetail(double wholesaleCost, double markupPercentage) {
        return wholesaleCost * (1 + markupPercentage / 100);
    }
}

 

 
 
 

Test Case 4

 
 
Please enter the wholesale cost or -1 exit:\n
-200ENTER
Wholesale cost cannot be a negative value.\n
Please enter the wholesale cost again or -1 exit:\n
10ENTER
Please enter the markup percentage or -1 exit:\n
-200ENTER
Markup cannot be less than -100%.\n
Please enter the markup again or -1 exit:\n
50ENTER
The retail price is: 15.00\n
Please enter the wholesale cost or -1 exit:\n
-1ENTER
 

Test Case 5

 
 
Please enter the wholesale cost or -1 exit:\n
-1ENTER
 
Test Case 1
Please enter the wholesale cost or -1 exit: \n
10 ENTER
Please enter the markup percentage or -1 exit: \n
-1 ENTER
Test Case 2
Please enter the wholesale cost or -1 exit: \n
100 ENTER
Please enter the markup percentage or -1 exit: \n
100 ENTER
The retail price is: 200.00 \n
Please enter the wholesale cost or -1 exit: \n
-1 ENTER
Transcribed Image Text:Test Case 1 Please enter the wholesale cost or -1 exit: \n 10 ENTER Please enter the markup percentage or -1 exit: \n -1 ENTER Test Case 2 Please enter the wholesale cost or -1 exit: \n 100 ENTER Please enter the markup percentage or -1 exit: \n 100 ENTER The retail price is: 200.00 \n Please enter the wholesale cost or -1 exit: \n -1 ENTER
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
Transcribed Image Text: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
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Constants and Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Information Technology Project Management
Information Technology Project Management
Computer Science
ISBN:
9781337101356
Author:
Kathy Schwalbe
Publisher:
Cengage Learning
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
Systems Analysis and Design (Shelly Cashman Serie…
Systems Analysis and Design (Shelly Cashman Serie…
Computer Science
ISBN:
9781305494602
Author:
Scott Tilley, Harry J. Rosenblatt
Publisher:
Cengage Learning