Question: In Java Progamming language: Can someone please fix the code for the problem below. Write a program that asks the user to enter an item's
In Java Progamming language: Can someone please fix the code for the problem below.
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 retail item's retail price is 10.00
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.
---------------------------------------------------------------------------------------------------------------------------
import java.util.Scanner;
public class calculateRetail { public static void main(String[] args) // main function { Scanner input = new Scanner(System.in); // scanner function is used to take input from user double w_cost; // here w_cost represents whole cost double mp; // mp represents markup percentage double rp ; //rp represents retail price System.out.println("Please enter whole sale cost"); w_cost = input.nextDouble(); System.out.println("please enter markup percentage"); mp = input.nextDouble(); retail_Price = cal_rp(w_cost, mp); // cal_rp represents calculate retail price System.out.println("Retail price: " + retail_Price); } public static double cal_rp(double wholesale, double markUp) { double m_conv = markUp/100; // m_conv means markup converter double m_amount = wholesale * m_conv; // m_amount means markup amount double retail = wholesale + m_amount; return retail; } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
