-1
I have to do the following exercise:
Make a program in Java that requests the total amount spent by the a store, print the payment options, request the desired option and prints the total amount of installments (if any).
1) Option: the view with 10% discount
2) Option: twice (label price)
3) Option: 3 to 10 times with 3% interest per month (only for purchases above R$ 100,00). Use the Switch command.
I’m having trouble finding where I’m going wrong in the code below:
The mistake is when I call the switch.
package Prova_A;
import java.util.Scanner;
public class Exe_02 {
    Scanner ler = new Scanner(System.in);
    int op() {
        Scanner ler = new Scanner(System.in);
        int op;
        System.out.println("*****Modo de Pagamento*****");
        System.out.println("1 - Á Vista");
        System.out.println("2 - 2 Vezes");
        System.out.println("3 - 3 Vezes");
        op = ler.nextInt();
        System.out.println("*******************************\n");
        return (op);
    }
    float aVista(float vlr) {
        System.out.println("Total R$: " + vlr);
        System.out.println("Total a pagar R$: " + vlr * 0.9);
        return (0);
    }
    float duasVezes(float vlr) {
        System.out.println("Total R$: " + vlr);
        System.out.println("Total a pagar R$: " + vlr / 2);
        return (0);
    }
    float tresVezes(float vlr) {
        int parcelas;
        System.out.println("Total R$: " + vlr);
        do {
            System.out.println("Informe a quantidade de parcelas :\n");
            parcelas = ler.nextInt();
        } while ((parcelas > 10) || (parcelas < 3));
        System.out.println("Parcelas de R$:\n " + parcelas + (vlr * 1.03) / parcelas);
        return (0);
    }
    public static void main(String[] args) {
        Scanner ler1 = new Scanner(System.in);
        float vlrCompra;
        int opcao;
        System.out.println("Informe o total da compra: \n");
        vlrCompra = ler1.nextFloat();
        System.out.println("***************************\n");
        switch(op){
            case 1:
                System.out.println("Pagamento a vista: \n");
                vlrCompra = ler.nextFloat();
                break;
        }
    }
}
I’m not seeing where you read the "op" on your switch
– Gustavo Fragoso
Gustavo, I’m trying to read here int op() { at the beginning of the code
– WillGreco