samedi 26 août 2017

How to access a variable inside of an if else if from the outside [duplicate]

This question already has an answer here:

I made a if else if statement:

if (null != ok) switch (ok) {
    case "ok":
        out.println("Thank you");
        out.println("If you are done press D. If not, press N.");
        double Totald1 = Total;
        double w1 = Totald1;
        double m1 = w1;
        double y1 = m1;
        double TotalO = y1;
        String done = sc.nextLine();
        if (null != done) switch (done) {
            case "D":
                System.out.println("Hope to see you again soon");
            break;
        case "N":
            out.println("What do you still want (press run at the top again)");
            break;
        }
        break;
    case "too high":
        out.println("ok, thank you for your business");
    break;
}

And I'm trying to put this: System.out.println("Total sales right now: " + TotalO); outside of the if else if but I can't access it, I also tried changing double to public double but then I got so many errors. Any help would be so appreciated.

Aucun commentaire:

Enregistrer un commentaire