1. import java.util.Scanner;
  2. public class retailPrice {
  3. public static void main (String[]args) {
  4. Scanner input = new Scanner(System.in);
  5. double wholesale, markup, retail=0;
  6. System.out.println("Enter the wholesale price! ");
  7. wholesale = input.nextDouble();
  8. System.out.println("Enter the markup percentage! ");
  9. markup = input.nextDouble();
  10. calculateRetail(wholesale, markup, retail);
  11. System.out.printf("The retail price of the item is %.2f\n ", retail); }
  12. public static double calculateRetail(double wholesale, double markup, double retail) {
  13. double percentage = markup / 100;
  14. return retail = percentage + wholesale; } }

    After running the program it returns 0.00 for the retail price...How do i fix this problem? Thanx

6 Years
Discussion Span
Last Post by ztini

Uh...right now your code is incomprehendable because of the lack of formatting. Please use the proper bbcodes so that we can actually understand your code.


i tried but i couldn't fix it. Its my second post in this site and i had a similar problem on the first 1 also. Could you tell me how to post lines of codes ? thank you !


If you had bothered to read the tips or guidelines before posting. You would already have found how to proprerly post code. Write: code =java in brackets and backslash code in brackets
When u are dome with your code in between the two bracket sets.

Edited by btsuper: n/a

import java.util.Scanner;

public class RetailPrice{
	public static double calculateRetail(double wholesale, double markup)	{
		return (markup / 100 + 1) * wholesale;
	public static void main (String[]args)	{
		Scanner input = new Scanner(System.in);
		System.out.println("Enter the wholesale price! ");
		double wholesale = input.nextDouble();
		System.out.println("Enter the markup percentage! ");
		double markup = input.nextDouble();

		System.out.printf("The retail price of the item is " +
				calculateRetail(wholesale, markup));

Remember to include your code in between the code tags (its to the right of where you adjust bold, italic, underline, and color when you are typing in a new message)...otherwise the forum nazis will get you.

This article has been dead for over six months. Start a new discussion instead.
Be sure to adhere to our posting rules.