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

Recommended Answers

All 4 Replies

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.

Member Avatar
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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.