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

You must describe what you do every step of the way with comments!!! Write a pro

ID: 3766975 • Letter: Y

Question

You must describe what you do every step of the way with comments!!!

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. Name the class Lastname05b and save the file as Lastname05b.java. USE YOUR LAST NAME INSTEAD OF THE WORD LASTNAME.

Use the Scanner class to grab the wholesale cost (double) and markup percentage (double).

Tell the user to enter a decimal instead of a percentage (.25, .50, etc)

Display the return value using a println() method in the MAIN method of your code: "The retail price of the item is " + retailPrice

The calculateRetail method should accept two double arguments and return a double.

HINT. You obtain the retail price by multiplying the wholesale cost by the percentage and ADDING it to the wholesale cost.

RETAIL PRICE = (WHOLESALE COST * MARKUP PERCENTAGE) + WHOLESALE COST

or

RETAIL PRICE = WHOLESALE COST * (1 + MARKUP PERCENTAGE)

Not only must your program meet the requirements of the problem,you must also:

Include your name and the program's purpose in a comment that appears before the class declaration.

Comment further in the lab as necessary.

Use the correct comment type for the Method, and parameters and return values

Follow the naming guidelines for Methods.

Your code should be "neat" with the proper indentation.

Explanation / Answer

Here is the code for you. If you have any further queries, just get back to me.

import java.io.*;
import java.util.Scanner;

public class RetailPriceCalculator
{
static double calculateRetail(double wholesalePrice, double markup) //Function to calculate the Retail price.
{
return wholesalePrice * (1 + markup); //Formula to calculate the Retail price.
}
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Enter the items wholesale cost: "); //Prompt the user to enter the wholesale cost.
double wholesalePrice = in.nextDouble();           //Read wholesalecost
System.out.print("Enter the mark up percentage (as a decimal value): ");   //Prompt the user to enter the markup.
double markup = in.nextDouble();                           //Read markup.
double retailPrice = calculateRetail(wholesalePrice, markup);//Call the function to calculate the Retail Price.
String output = String.format("The retail price of the item is: %.2f",retailPrice); //Convert the retailPrice to 2 digit precision.
System.out.println(output);   //Display the output.
}
}

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