Advertisement
thotfrnk

methods4.java

Dec 7th, 2022 (edited)
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. //class work.
  2.  
  3. import java.util.Scanner;
  4. public class number4 {
  5.     public static void main(String[] args) {
  6.  
  7.         Scanner input = new Scanner (System.in);
  8.  
  9.         double price, rate;
  10.  
  11.         System.out.println("Price of Item: ");
  12.         price = input.nextDouble();
  13.  
  14.         System.out.println("Discount Rate: ");
  15.         rate = input.nextDouble();
  16.  
  17.         System.out.println("Discounted Price: " +discount(price, rate));
  18.     }
  19.  
  20.     public static double discount(double price, double rate) {
  21.         double discount, discount_amt;
  22.  
  23.         discount_amt = price * rate;
  24.  
  25.         discount = price - discount_amt;
  26.  
  27.         return discount;
  28.  
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement