Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In Java Progamming language: Feel free to either correct my code or write your o

ID: 3818226 • Letter: I

Question

In Java Progamming language: Feel free to either correct my code or write your own, whichever you prefer to answer this question. If writing one’s own code, please comment in code.

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.

---------------------------------------------------------------------------------------------------------------------------------

My Code Attempt (feel free to use, edit, or write your own)

import javax.swing.JOptionPane;

class RetailPrice
{
   public static void main(String args[])
   {
      double wSaleCost;
      double markPerc;
      double retailPrice;
    
      String input;
      input = JOptionPane.showInputDialog("Enter " + "whole sale cost:");
    
      wSaleCost = Double.parseDouble(input);
    
      input = JOptionPane.showInputDialog("Enter" + "mark up percentage:");
    
      markPerc = Double.parseDouble(input);
    
      retailPrice = calculateRetail(wSaleost,markPerc);
    
      JOptionPane.showMessageDialog(null, "Retail price :" + retailPrice);
    
      System exit(0);
      }
    
      public static double calculateRetail(double wholeSCost, double percent)
      {
      double retail = 0;
      retail = wholeSCost + ((wholeSCost * percent) / 100);
      return retail;
   }
}

Explanation / Answer

Hi here is my code if you have any problem with this code please comment below.....

import java.util.Scanner;

// here you can give class name anything here I mentioned as test, if you want to write like in your program...RetailPrice you can write it
public class test   
{
    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;
    }

Thnak you

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote