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 code: please modify this code so it works in Hypergrade when I submit it so it passes all the test casses in Hypergrade. It has to pass all the test casses in Hypergrade becausw when I submit the code in Hypercase it does not run and it says 0 out of 5 casses passed. Please fix this code. I do not need thanks for playing or goodbye in  the program.      import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class FileRead { public static void main(String[] args) throws FileNotFoundException { Scanner keyboard = new Scanner(System.in); System.out.println("Please enter the file name or type QUIT to exit:"); String filename = keyboard.nextLine(); if (filename.equalsIgnoreCase("Quit")) return; File myFile = new File(filename); while (!myFile.exists()) { System.out.println("File: " + filename + " does not exist."); System.out.println("Please enter the file name again or type QUIT to exit:"); filename = keyboard.nextLine(); if (filename.equalsIgnoreCase("Quit")) { return; } myFile = new File(filename); } Scanner inputFile = new Scanner(myFile); int lines = 0; while (inputFile.hasNext()) { String str = inputFile.nextLine(); lines++; System.out.println(lines + ": " + str); } inputFile.close(); } }   Test Case 1     Please enter the wholesale cost or -1 exit:\n 10ENTER Please enter the markup percentage or -1 exit:\n -1ENTER   Test Case 2     Please enter the wholesale cost or -1 exit:\n 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 10ENTER Please enter the markup percentage or -1 exit:\n 50ENTER The retail price is: 15.00\n Please enter the wholesale cost or -1 exit:\n 10ENTER Please enter the markup percentage or -1 exit:\n 100ENTER The retail price is: 20.00\n Please enter the wholesale cost or -1 exit:\n 10ENTER Please enter the markup percentage or -1 exit:\n -100ENTER The retail price is: 0.00\n Please enter the wholesale cost or -1 exit:\n -1ENTER   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

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 27PE
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 code: please modify this code so it works in Hypergrade when I submit it so it passes all the test casses in Hypergrade. It has to pass all the test casses in Hypergrade becausw when I submit the code in Hypercase it does not run and it says 0 out of 5 casses passed. Please fix this code. I do not need thanks for playing or goodbye in  the program. 
 
 

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class FileRead {
public static void main(String[] args) throws FileNotFoundException {
Scanner keyboard = new Scanner(System.in);
System.out.println("Please enter the file name or type QUIT to exit:");
String filename = keyboard.nextLine();
if (filename.equalsIgnoreCase("Quit"))
return;

File myFile = new File(filename);
while (!myFile.exists()) {
System.out.println("File: " + filename + " does not exist.");
System.out.println("Please enter the file name again or type QUIT to exit:");
filename = keyboard.nextLine();
if (filename.equalsIgnoreCase("Quit")) {
return;
}
myFile = new File(filename);
}

Scanner inputFile = new Scanner(myFile);
int lines = 0;
while (inputFile.hasNext()) {
String str = inputFile.nextLine();
lines++;
System.out.println(lines + ": " + str);
}
inputFile.close();
}
}

 

Test Case 1

 
 
Please enter the wholesale cost or -1 exit:\n
10ENTER
Please enter the markup percentage or -1 exit:\n
-1ENTER
 

Test Case 2

 
 
Please enter the wholesale cost or -1 exit:\n
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
10ENTER
Please enter the markup percentage or -1 exit:\n
50ENTER
The retail price is: 15.00\n
Please enter the wholesale cost or -1 exit:\n
10ENTER
Please enter the markup percentage or -1 exit:\n
100ENTER
The retail price is: 20.00\n
Please enter the wholesale cost or -1 exit:\n
10ENTER
Please enter the markup percentage or -1 exit:\n
-100ENTER
The retail price is: 0.00\n
Please enter the wholesale cost or -1 exit:\n
-1ENTER
 

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
Expert Solution
steps

Step by step

Solved in 4 steps with 6 images

Blurred answer
Knowledge Booster
Mathematical functions
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
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning