joseleonweb

Untitled

Sep 21st, 2019
120
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2. //Un programa que calcula descomptes.
  3.  
  4. public class Descompte {
  5.     //PAS 1
  6.     //Es fa un descompte del 8%.
  7.     public static final float DESCOMPTE =8;
  8.     //Es fa descompte per compres d’un mínim de 100 euros.
  9.     public static final float COMPRA_MIN = 100;
  10.     public static void main (String[] args) {
  11.         Scanner lector = new Scanner(System.in);
  12.         //PAS 2 i 3
  13.         System.out.print("Quin és el preu del producte, en euros? ");
  14.         float preu = lector.nextFloat();
  15.         lector.nextLine();
  16.         //PAS 4
  17.         //Estructura de selecció simple.
  18.         //Si l’expressió avalua true, executa el bloc dins l’if.
  19.         //En cas contrari, ignora’l.
  20.         if (preu >= COMPRA_MIN) {
  21.             //PAS I 21 float descompteFet = preu * DESCOMPTE / 100;
  22.             preu = preu − descompteFet;
  23.         }
  24.         //PAS 5
  25.         System.out.println("El preu final per pagar és de " + preu + " euros.");
  26.     }
  27. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×