Created
April 26, 2012 13:50
-
-
Save douglasiacovelli/2499751 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Scanner; | |
| public class Loja{ | |
| static double calca = 100.00, camisa = 99.99, blusa = 75.10, sapato = 125.00, bermuda = 85.90, bone = 50.00, camiseta = 73.20; | |
| static int codigoProduto; | |
| static int [] listaCompra = new int [100]; | |
| static int posicao = 0; | |
| public static void Lista () { | |
| System.out.println("\n \t menu \n" ); | |
| System.out.println("1. Calca = R$ " + calca ); | |
| System.out.println("2. Camisa = R$ " + camisa); | |
| System.out.println("3. Blusa = R$ " + blusa); | |
| System.out.println("4. Sapato = R$ " + sapato); | |
| System.out.println("5. Bermuda = R$ " + bermuda); | |
| System.out.println("6. Bone = R$ " + bone); | |
| System.out.println("7. Camiseta = R$ " + camiseta + "\n"); | |
| System.out.println("Caso queira encerrar a compra, digite: 0\n"); | |
| } | |
| public static void main (String[] args){ | |
| do { | |
| Lista(); | |
| Scanner entrada = new Scanner (System.in); | |
| System.out.println("Digite o código do produto"); | |
| codigoProduto = entrada.nextInt(); | |
| if (codigoProduto != 0){ | |
| if (codigoProduto >= 1 && codigoProduto <= 7){ | |
| listaCompra[posicao] = codigoProduto; | |
| posicao++; | |
| } | |
| else { | |
| System.out.println ("Não existe essa opcao"); | |
| } | |
| } | |
| } while (codigoProduto !=0); | |
| System.out.println("Compra finalizada"); | |
| double TotalCompra=0; | |
| for (int n=0; n<posicao; n++){ | |
| switch (listaCompra[n]) { | |
| case 0: break; | |
| case 1: System.out.println ("Calca \t R$"+calca); | |
| TotalCompra+= calca; | |
| break; | |
| case 2: System.out.println ("Camisa \t \t\tR$"+camisa); | |
| TotalCompra+= camisa; | |
| break; | |
| case 3: System.out.println ("Blusa \t\t\t R$"+blusa); | |
| TotalCompra+= blusa; | |
| break; | |
| case 4: System.out.println ("Sapato \t\t\t R$"+sapato); | |
| TotalCompra+= sapato; | |
| break; | |
| case 5: System.out.println ("Bermuda \t\t\t R$"+bermuda); | |
| TotalCompra+= bermuda; | |
| break; | |
| case 6: System.out.println ("Bone \t\t\t R$"+bone); | |
| TotalCompra+= bone; | |
| break; | |
| case 7: System.out.println ("Camiseta \t\t\t R$"+camiseta); | |
| TotalCompra+= camiseta; | |
| break; | |
| default: System.out.println ("Não existe essa opcao"); | |
| } | |
| } | |
| System.out.printf("Total da conta:\t\t R$%.2f \n ",TotalCompra); | |
| } | |
| } | |
| //compra = Double.parseDouble(JOptionPane.showInputDialog("valor produto")); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment