Sunday, March 28, 2021

Discount Price Using User Defined Function in Java

Machine Problem

Write a program to ask the user the product name, marked price, and percent of discount of the product. The program will compute the amount after the discount of the product.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com






Program Listing


/* Discount_Price.java

 * Author : Jake Rodriguez Pomperada, MAED-IT, MIT

 * March 28, 2021  3:53 PM Sunday

 * www.jakerpomperada.blogspot.com

 * www.jakerpomperada.com

 * jakerpomperada@gmail.com

 * Bacolod City, Negros Occidental

 * 

 * Machine Problem in Java

 * 

 * Write a program to ask the user the product name,marked price,

 * and percent of discount of the product. The program will compute

 * the amount after the discount of the product.

 * 

 */

import java.util.Scanner;



public class Discount_Price {


public static void main(String args[])

{

 

  double  dis,amount,markedprice,s;

  String product;

Scanner input=new Scanner(System.in);

System.out.print("\n\n");

System.out.print("\tDiscount Price Using User Defined Function in Java");

System.out.print("\n\n");

System.out.print("\tEnter Product      : ");

product = input.nextLine();

System.out.print("\tEnter Marked Price : ");

               

markedprice= input.nextDouble();

 

       System.out.print("\tEnter Discount Percentage : ");

               

dis=input.nextDouble();

     s=100-dis;

 

      amount =    calcuateDiscount(markedprice,s);

   

    System.out.print("\n\n");

    System.out.print("\tProduct Name   : "+product+"\n\n");  

System.out.println("\tAmount After Discount: PHP "+ String.format("%.2f",amount));

input.close();

  }

static double calcuateDiscount(double markedprice,double s)

    {                   

      double amount= (s*markedprice)/100;

      return amount;


     }

}


No comments:

Post a Comment