Advertisement
Guest User

Untitled

a guest
May 24th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package victor_oo_produtoq4;
  7.  
  8. /**
  9. *
  10. * @author vscon_000
  11. */
  12. import java.util.Scanner;
  13. public class Victor_OO_ProdutoQ4 {
  14. public static void imprimir_Resultado(String nome,double preco){
  15. System.out.println("O produto de nome: " + nome + " foi comprado por: " + preco);
  16. }
  17. /**
  18. * @param args the command line arguments
  19. */
  20. public static void main(String[] args) {
  21. // TODO code application logic here
  22. Scanner teclado = new Scanner(System.in);
  23. String sair = " ";
  24. do{
  25. System.out.println("Entre com o nome do produto: ");
  26. String nome = teclado.next();
  27. System.out.println("Entre com a quantidade: ");
  28. int qtd = teclado.nextInt();
  29. System.out.println("Entre com o preco: ");
  30. double preco = teclado.nextDouble();
  31. if((qtd > 0) && (qtd <= 10)){
  32. double preco_Total = qtd * preco;
  33. imprimir_Resultado(nome,preco_Total);
  34. }
  35. else if((qtd > 10) && (qtd<=20)){
  36. double preco_Total = (0.9 * preco) * qtd;
  37. imprimir_Resultado(nome,preco_Total);
  38. }
  39. else{
  40. System.out.println("Quantidade do produto nao pode ser superior a 20 nem inferior a 0");
  41. }
  42. System.out.println("Digite n se quiser sair ou outra coisa para continuar");
  43. sair = teclado.next();
  44. }while(sair.toUpperCase().equals("N") != true);
  45.  
  46. }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement