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.
- */
- /**
- *
- * @author alann
- */
- import java.util.ArrayList;
- import java.util.Scanner;
- public class Principal {
- public static void main(String args[]){
- ArrayList<Compra> newcompra = new ArrayList<>();
- Scanner ent = new Scanner(System.in);
- String n, u, l, t, aux3, aux4, aux5, aux6, aux7, aux8, mes;
- float q, p, mult, total = 0, aux = 0, aux2 = 100, aux10;
- int a = 0, b, aux9, aux11 = 0;
- while(a != 7){
- System.out.println("O que deseja fazer?\n1 - Lista de Compra (Anterior)\n2 - Consultar produtos por local\n3 - Cadastro de Produto (Previsão)\n4 - Lista de Previsão\n5 - Alterar Produto\n6- Produto mais e menos comprado\n7 - Sair\n");
- a = ent.nextInt();
- switch (a){
- case 1:
- Compra c1 = new Compra(null, null, null, null, 0, 0);
- c1.setNomep("Arroz");
- c1.unidade = "Kg";
- c1.local = "Atacadão";
- c1.quantidade = 7;
- c1.preco = (float) 2.2;
- newcompra.add(c1);
- Compra c2 = new Compra(null, null, null, null, 0, 0);
- c2.setNomep("Feijão");
- c2.unidade = "Kg";
- c2.local = "Atacadão";
- c2.quantidade = 5;
- c2.preco = (float) 2.99;
- newcompra.add(c2);
- Compra c3 = new Compra(null, null, null, null, 0, 0);
- c3.setNomep("Leite");
- c3.unidade = "l";
- c3.local = "São Luiz";
- c3.quantidade = 8;
- c3.preco = 2;
- newcompra.add(c3);
- Compra c4 = new Compra(null, null, null, null, 0, 0);
- c4.setNomep("Carne");
- c4.unidade = "Kg";
- c4.local = "Bella Compra";
- c4.quantidade = 10;
- c4.preco = (float) 7.5;
- newcompra.add(c4);
- System.out.println("Lista de compras");
- System.out.println("Julho\n");
- for(b = 0; b < newcompra.size();b++){
- newcompra.get(b).listaProdutos();
- System.out.println("");
- }
- System.out.println("\nTotal gasto: R$ "+(c1.y+c2.y+c3.y+c4.y)+"\n");
- break;
- case 2:
- System.out.println("Qual local deseja consultar?");
- aux3 = ent.nextLine();
- aux3 = ent.nextLine();
- aux4 = aux3.toUpperCase();
- for(b = 0; b < newcompra.size();b++){
- aux5 = newcompra.get(b).local.toUpperCase();
- if(aux4.equals(aux5)){
- newcompra.get(b).listaProdutosPrevisao();
- }
- }
- break;
- case 3:
- System.out.println("");
- System.out.println("Nome do Produto:");
- n = ent.nextLine();
- n = ent.nextLine();
- System.out.println("Unidade de Medida:");
- u = ent.next();
- System.out.println("Local:");
- l = ent.nextLine();
- l = ent.nextLine();
- System.out.println("Tipo");
- t = ent.next();
- System.out.println("Quantidade:");
- q = ent.nextFloat();
- System.out.println("Preco:");
- p = ent.nextFloat();
- System.out.println("");
- newcompra.add(new Compra(n, u, l, t, q, p));
- break;
- case 4:
- System.out.println("");
- System.out.println("Lista de Previsão");
- System.out.println("Agosto\n");
- for(b = 0; b < newcompra.size();b++){
- newcompra.get(b).listaProdutosPrevisao();
- System.out.println("");
- }
- for(b = 0; b < newcompra.size();b++){
- total = total + newcompra.get(b).y;
- }
- System.out.println("\nTotal previsto: R$ "+total);
- System.out.println("");
- break;
- case 5:
- System.out.println("Qual produto deseja alterar?");
- aux6 = ent.nextLine();
- aux6 = ent.nextLine();
- aux7 = aux6.toUpperCase();
- for(b = 0; b < newcompra.size();b++){
- aux8 = newcompra.get(b).getNomep().toUpperCase();
- if(aux7.equals(aux8)){
- System.out.println("O que deseja alterar?\n1 - Local\n2 - Tipo\n3 - Quantidade\n4 - Preco");
- aux9 = ent.nextInt();
- switch (aux9){
- case 1:
- System.out.println("Novo Local:");
- newcompra.get(b).local = ent.nextLine();
- newcompra.get(b).local = ent.nextLine();
- break;
- case 2:
- System.out.println("Novo Tipo:");
- newcompra.get(b).tipo = ent.next();
- break;
- case 3:
- total = total - newcompra.get(b).y;
- System.out.println("Nova quantidade:");
- newcompra.get(b).quantidade = ent.nextFloat();
- break;
- case 4:
- total = total - newcompra.get(b).y;
- System.out.println("Novo Preco:");
- aux10 = ent.nextFloat();
- newcompra.get(b).setPreco(aux10);
- break;
- default:
- break;
- }
- }
- }
- break;
- case 6:
- for(b = 0; b < newcompra.size();b++){
- if(newcompra.get(b).quantidade >= aux){
- aux = newcompra.get(b).quantidade;
- }else {
- }
- if(newcompra.get(b).quantidade <= aux2){
- aux2 = newcompra.get(b).quantidade;
- }else{
- }
- }
- System.out.println("Produto(s) mais comprado(s)");
- for(b = 0; b < newcompra.size();b++){
- if(aux == newcompra.get(b).quantidade){
- newcompra.get(b).listaProdutosPrevisao();
- }
- }
- System.out.println("\nProduto(s) menos comprado(s)");
- for(b = 0; b < newcompra.size();b++){
- if(aux2 == newcompra.get(b).quantidade){
- newcompra.get(b).listaProdutosPrevisao();
- }
- }
- break;
- default:
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement