Calculation Water consumption in Java using IDE Eclipse

4

I'm having trouble writing this exercise in the Java Language, using the Eclipse IDE:

  

The director of a state school in the city of São Paulo is terrified of the absurd consumption of water that is occurring monthly. In order to gather information that will lead you to make cost containment decisions, she hired you to develop a program that will read the month's water consumption in m3 and report the amount of the bill.   Data: consider that each m3 is worth R $ 2.00; In addition, R $ 20.00 of sewage and 15% of taxes are added.

I can not get the program to do the calculations. In my case I first have to calculate the tax, then "play" it in the formula to calculate the value of water consumption.

MY CODE

import java.io.IOException;
import java.util.Scanner;

public class Agua {

    public static void main(String[] args) throws IOException  {

        int consumo;
        int valore;
        int imposto;

                System.out.println("Informar o valor do consumo");

                Scanner Leio = new Scanner(System.in);
                consumo = Leio.nextInt();

                imposto = (2 * consumo + 20) * 15/100;
                System.out.println("O imposto é ");


                System.out.println("Informe o valor do imposto");
                valore = (2 * consumo + 20) + imposto;

                System.out.println("O Valor é de: R$ ");
                Leio.close();

            }

}

I have difficulties in this exercise, because after I type the value of the consumption nothing happens!

Below is the formulas by VisualG where the caculars occur without problems (crazy teacher wants Portugol / Visualg and Java)!

MysecondimageisthescreeninEclipseafterIenterthevalueof"consumption"

    
asked by anonymous 16.03.2018 / 12:38

2 answers

1

Look at java is much more malleable than portugol, you can do this, if you do not understand anything you can ask me. Okay?

public class Agua {

    public static void main(String[] args) throws IOException {
        System.out.println("Informar o valor do consumo");
        Scanner Leio = new Scanner(System.in);
        int consumo = Leio.nextInt();
        int imposto = (2 * consumo + 20) * 15 / 100;
        System.out.println("O imposto é " + imposto);
        System.out.println("Informe o valor do imposto");
        int valore = (2 * consumo + 20) + imposto;
        System.out.println("O Valor é de: R$ " + valore);
    }
}
    
16.03.2018 / 18:32
4

You are not printing tax and consumption figures. What you do is just print the text:

System.out.println("O imposto é ");
...
System.out.println("O Valor é de: R$ ");

Notice that in your VisualGen code you actually print the value:

Escreva(Valor)

The only adjustment you need to make is to add the impression of the value of the variable, just as you did in VisualG:

System.out.println("O imposto é ");
System.out.println(imposto);
...
System.out.println("O Valor é de: R$ ");
System.out.println(valore);

So the values you calculated will appear on the console.

    
16.03.2018 / 13:24