Return a value from a two-variable calculation to show the user using POO. Result is not printed on screen

Asked

Viewed 26 times

-1

Scanner deltas = new Scanner(System.in);
            Double ds;
            System.out.println("Insira o valor de Delta S");
            ds = deltas.nextDouble();
            setDeltas(ds);

            Scanner deltat = new Scanner(System.in);
            Double dt;
            System.out.println("Insira o valor de Delta S");
            dt = deltat.nextDouble();
            setDeltat(dt);

            Double velo = ds/dt;

            System.out.printf ("Sua velocidade media é: ", velo);

1 answer

1


  1. Use only one Scanner.

  2. Use the printf correctly. Or use the println.

Your corrected code:

            Scanner sc = new Scanner(System.in);

            System.out.println("Insira o valor de Delta S");
            double ds = sc.nextDouble();
            setDeltas(ds);

            System.out.println("Insira o valor de Delta S");
            double dt = sc.nextDouble();
            setDeltat(dt);

            double velo = ds / dt;

            System.out.println("Sua velocidade média é: " + velo);
  • Thank you very much!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.