Write the pseudo code for the following: Write a program that asks the user to e
ID: 3572964 • Letter: W
Question
Write the pseudo code for the following:
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%, then the item's retail prices is 10.00.
If an item's wholesale cost is 5.00 and its markup percentage is 50%, then the item's retail price is 7.50.
The program should have a function named calculateRetail that receives the wholesale cost and the markup percentage as arguments and returns the retail price of the item
Explanation / Answer
RetailCostTest.java
import java.util.Scanner;
public class RetailCostTest {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Enter an item's wholesale cost: ");
double wholesaleCost = scan.nextDouble();
System.out.print("Enter markup percentage: ");
double percentage = scan.nextDouble();
double retailCost = calculateRetail(wholesaleCost, percentage);
System.out.println("Retail cost is "+retailCost);
}
public static double calculateRetail (double wholesaleCost, double percentage){
double retailCost = wholesaleCost + (wholesaleCost * percentage)/100;
return retailCost;
}
}
Output:
Enter an item's wholesale cost: 10
Enter markup percentage: 100
Retail cost is 20.0
Enter an item's wholesale cost: 5
Enter markup percentage: 50
Retail cost is 7.5
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.