Advertisement
Guest User

Untitled

a guest
Nov 14th, 2018
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Payment
  3. {
  4.     public static void main(String[] nrCoins)
  5.     {
  6.         Scanner input = new Scanner(System.in);
  7.         String coinsAvailable = nrCoins[0];
  8.         double price,recieved;
  9.         char c = coinsAvailable.charAt(0);
  10.         int coin2,cashBack,centC, centD,centU;
  11.         int someCoins=(c-'0');
  12.        
  13.         System.out.println("Maquina carregada com "+someCoins+" moedas de cada tipo");
  14.        
  15.         do{
  16.             System.out.print("Preco(em euros)? ");
  17.             price = input.nextDouble();
  18.         }while(price!=0);
  19.         while(){
  20.             System.out.print("Quantia recebida(em euros)? ");
  21.             recieved = input.nextDouble();
  22.             int changeCents = ((int)recieved-price)*100;
  23.             centC=changeCents/100;
  24.             centD=(changeCents%100)/10;
  25.             centU=(changeCents%100)%10
  26.             for(int counterCoins2=someCoins;(centC>=4&&centC%2=0)||centC=2;--counterCoins2){
  27.                 ++coin2;
  28.             }
  29.             centC-=coin2;
  30.             while(centC<2)
  31.            
  32.        
  33.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement