Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package victor_oo_produtoq4;
- /**
- *
- * @author vscon_000
- */
- import java.util.Scanner;
- public class Victor_OO_ProdutoQ4 {
- public static void imprimir_Resultado(String nome,double preco){
- System.out.println("O produto de nome: " + nome + " foi comprado por: " + preco);
- }
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- Scanner teclado = new Scanner(System.in);
- String sair = " ";
- do{
- System.out.println("Entre com o nome do produto: ");
- String nome = teclado.next();
- System.out.println("Entre com a quantidade: ");
- int qtd = teclado.nextInt();
- System.out.println("Entre com o preco: ");
- double preco = teclado.nextDouble();
- if((qtd > 0) && (qtd <= 10)){
- double preco_Total = qtd * preco;
- imprimir_Resultado(nome,preco_Total);
- }
- else if((qtd > 10) && (qtd<=20)){
- double preco_Total = (0.9 * preco) * qtd;
- imprimir_Resultado(nome,preco_Total);
- }
- else{
- System.out.println("Quantidade do produto nao pode ser superior a 20 nem inferior a 0");
- }
- System.out.println("Digite n se quiser sair ou outra coisa para continuar");
- sair = teclado.next();
- }while(sair.toUpperCase().equals("N") != true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement