Guest User

Untitled

a guest
Jan 3rd, 2019
631
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import java.text.DecimalFormat;
  2. import java.text.NumberFormat;
  3. import java.util.Scanner;
  4.  
  5. public class CalculateDiscount {
  6. public static void main(String[] args) {
  7. Scanner user_input = new Scanner(System.in);
  8.  
  9. Integer n = Integer.parseInt(user_input.nextLine());
  10. Double item_price;
  11. Double discounted_price[] = new Double[n];
  12. NumberFormat formatter = new DecimalFormat("#0.00");
  13.  
  14. for (int i = 0; i < n; i++) {
  15. item_price = Double.parseDouble(user_input.nextLine());
  16. discounted_price[i] = item_price * 0.35;
  17. }
  18.  
  19. for (int j = 0; j < discounted_price.length; j++) {
  20. System.out.printf(formatter.format(discounted_price[j]) + "\n");
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment